collection = new nx.Collection
	items: [ # not strings but actually Cells
		name: 'France'         capital: 'Paris'   # ...
		name: 'Germany'        capital: 'Berlin'
		name: 'United Kingdom' capital: 'London'
		name: 'Spain'          capital: 'Madrid'
	]

refined.source.value = collection # nx.RefinedCollection
refined.refinement.value = nx.FilterRefinement
	filter: (name) -> /F/.test name
	values: (country) -> country.name.value
# Changing both leads to a reset

# refinement's action applies refinement

# refinement:
refinement

nx.Refinement transform

# nx.FilterRefinement returns a converting function for command binding:
# nx.Command -> nx.Command

# collection.append

# Map
vms = collection.map (item) -> new ViewModel item

# Filter

filtered_by_name = collection.filter
	filter: (name) -> /F/.test name
	values: (country) -> country.name.value
	# or perhaps sugary shortcut:
	values: ['name']

# Sort

sorted_by_population = collection.sort
	compare: (first, second) -> first - second # default
	values: ['population']

# Dynamic refinement (using refinement cell)

filtered_by_name = collection.filter
	filter: (name) -> /F/.test name
	values: ['name']

filtered_by_name.refinement['<-'] query_input, (query) ->

	(name) -> (new Regex query).test name

# Live Map

collection = new nx.Collection
	# ...
	transform: nx.LiveTransform
		(country) -> [country.population, country.area]
		# or sugar-coated:
		nx.LiveTransform ['population', 'area']

density = collection.map
	map: (population, area) -> population / area
	values: ['population', 'area']

# Live Filter

collection = new nx.Collection
	# ...
	transform: nx.LiveTransform ['name']

filtered_by_name = collection.filter
	filter: (name) -> /F/.test name
	values: ['name']

# Live Sort (WIP)

# collection = new nx.Collection
# 	# ...
# 	transform: nx.LiveTransform ['population']

# sorted_by_population = new nx.RefinedCollection collection,
# 	compare: (first, second) -> first - second
# 	live:


# Warp: sync conflicts (versioning? per-resource resetting)
# Sorting

@books = new nx.Collection
@query = new nx.Cell

@filtered_books = @books.filter
	values: ['title', 'author']
	filter: new nx.Cell
		'<-': [
			@query, (query) ->
				(title, author) -> # match title and author with `query`
			]

