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

Synapse.sync conflicts with Backbone.sync #18

Closed blocka closed 12 years ago

blocka commented 12 years ago

After a backbone model is augmented with Synapse(model), it now contains a sync method.

Then when you save, backbone calls return (this.sync || Backbone.sync).call(this, method, this, options); and since this.sync is defined, it will call the "overwritten" sync method.

bruth commented 12 years ago

Indeed. Do you have a name suggestion?

blocka commented 12 years ago

I was thinking about this a little. Then I realized that my use case actually required a little more control over the options for notify and observe, so I manually did Synapse(observer).notify(subject,options1).observe(observer,options2).

So I stopped thinking about it

bruth commented 12 years ago

Ok. On a side note, I noticed you are having the observer observe itself for state changes. Is this a common pattern you are using? What are the two types of objects involved? I am curious because there may be a shortcut API in there somewhere for observing an object's own state changes.

blocka commented 12 years ago

Let me look at my code again. I was writing from memory, but what I actually did was copy the code from the sync method.

What I'm doing should be a normal "sync". I have form elements which observe a Backbone model, and in turn notify the Backbone model.

The only thing different, is that I need control over the formatting (think dates) going from Backbone to the form, and then from the form back to Backbone.

blocka commented 12 years ago

Actually what am I saying...its a conflict whether I use Synapse.sync or not. So an alternative name needs to be thought of or another approach.

blocka commented 12 years ago

How about syncTo or syncWith?