Closed blocka closed 12 years ago
Indeed. Do you have a name suggestion?
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
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.
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.
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.
How about syncTo
or syncWith
?
After a backbone model is augmented with
Synapse(model)
, it now contains async
method.Then when you save, backbone calls
return (this.sync || Backbone.sync).call(this, method, this, options);
and sincethis.sync
is defined, it will call the "overwritten"sync
method.