Open bruth opened 12 years ago
So, the arguments that can be passed into observe
and notify
:
Simple positional
subject.notify(observer, [getHandler], [setHandler], [converter]);
Configuration object
subject.notify(observer, options);
Observer-based (notify
only)
The observer-based configuration (as discussed above)
subject.notify(observerOptions);
One thing I go back and forth with is which aspect of the binding is the focal point. An example of a target-focused configuration:
An object is passed with each key being the observer while each value is the
setHandler
. This binding would read:In this simple example, the
event
('change') and thegetHandler
('prop:checked') are detected for the':checkbox'
element. For custom bindings, the value of the object can be an object itself:In this example, the binding would read:
With a
Backbone.Model
instance as the notifier, this works also, but is a bit verbose:The biggest problem with this configuration is that keys can only be strings (i.e. jQuery/Zepto selectors). My gut reaction to this is that it's ok. The primary usage Synapse typically is
model
→DOM
orDOM
→DOM
. That being said, if thesubject
is amodel
, than the values of each binding could be themodel
attribute (getHandler
).Thoughts?