bruth / synapse

Hooks to support data binding between virtually any object.
http://bruth.github.com/synapse/docs/
BSD 2-Clause "Simplified" License
150 stars 6 forks source link

Add constructor parameter, `extend`, to extend and return the coerced object #11

Closed bruth closed 12 years ago

bruth commented 12 years ago

Derived from #1. The Synapse constructor can take a boolean designating whether to wrap the passed in object with the public API methods observe, notify, and sync, i.e. Synapse(object, [extend]):

var elem = Synapse('input', true), // returns the matched object for the hook (e.g. jQuery object)
    data = Synapse({}, true);

data.observe(elem);

elem instanceof jQuery; // true
bruth commented 12 years ago

Slight change.. using Synapse as a function (rather than a constructor with new) augments the object that is passed in with observe, notify, and sync.