Open benjamminf opened 10 years ago
Hrmm that's tricky since the objects aren't observed, they rely on get/set. I eventually want to switch it to Object.observe so this will be easier.
For now, you might want to just pass in another type of model to the views and listen for changes manually.
var model = new Model();
model.set('foo', 'bar');
var View = ripple(template);
View.on('created', function(view){
view.data.model.on('change foo', function(val){
view.set('foo', val);
});
});
new View({
data: {
model: model
}
});
It's not pretty at all. You'd just watch that object for changes and then set another property on the view. Then you could do this in both views.
Is there any way to use a central data source that multiple views make and watch for changes with?
I've toyed around with having models share observers but it fails when you have nested views (so when using the each plugin).
Also, brilliant work you've done with this framework! It's been very useful, so thank you.