montagejs/montage — pull request #1104 by kriskowal (2013-01-24 19:48:10+00:00)
Title: Integrate bindings

This is a huge truck coming in. Everyone should review this.

Everything that overlaps a service provided by Collections or FRB is removed and replaced. I’ve made a first pass at revising everything in Montage that depends on these subsystems to keep them working, but I have missed a lot, and most projects that depend on Montage will have to stop at v0.12 and make some changes.

- Selector
- Bindings
- Use Montage.defineBinding and Montage.cancelBinding with the same notation as used in the serialization
- `.count()` paths translated to `.length`
- `array.property` translated to `array.map{property}`
- `undefinedGet`, `undefinedSet`, `getProperty` and `setProperty` have been replaced with the Collection protocol, `get`, `set`, and `getDefault`, which do not apply to properties but rather to collection keys. As such, anything that needs to be treated as a mapping collection must actually *be* a mapping collection, like erstwhile `FakeObjects`, which has been replaced by a `Map` called `objectForIteration`.
- The `addPropertyBindingListener` (or whatever it was called) is no more. It has been replaced with `observeKey` and `observeProperty`, which FRB delegates to if they exist, and they must comply with the FRB observer protocol, which is to say that they must accept `emit`, `source`, `parameters`, and `beforeChange` and return a `cancel` function. FRB provides `Observers.observeKey` and `Observers.observeProperty` which make it easy to delegate a binding to another object and an alternate key or property name.
- Bindings serialization units
- No migration step necessary in serializations, except for above binding notation changes.
- Dependent properties are gone. Computed properties are in, but are not the same. I think we will need a concept of lazy bindings in Montage.defineProperty and Montage.create protocol, akin to distinct properties, using binding notation, and enabling a binding on first access.
- Change listeners implementation
- Anything depending on these directly will need to consult the corresponding feature of Collections. The interface is pretty different.
- Many shims
- Repetition has been revised. I’m still working on getting things to work on top of it, like Flow. Some of the interface has changed, but I’m preserving as much as possible like the properties `objectAtCurrentIteration`, `objects`, and `contentController`.
- `indexMap` is now a `visibleIndexes` collection. It may be any collection that produces range change events, which includes Array and SortedSet.
- `selectedIndexes` is gone. Use `selectedIterations` or `selection` (selected objects, which is two-way bound the `selected` property of each iteration)
- `activeIndexes` is also gone, Use `activeIterations` or the `active` property of each iteration.
- ArrayController is dead. Long live ContentController.
- `sortFunction` and `filterFunction` are replaced by `selector`, which is an FRB selector path like `sorted().filter{name.startsWith('A')}`.
- Adds TreeController
- Adds PromiseController