ripplejs / ripple

A tiny foundation for building reactive views
http://ripplejs.github.io
1.28k stars 66 forks source link

ripple vs. reactive #3

Closed matthewmueller closed 10 years ago

matthewmueller commented 10 years ago

would love to see a little section in the readme or this issue about the differences / design decisions between these two reactive engines.

anthonyshort commented 10 years ago

I'm still finishing ripple :)

But the main differences are they way it handles models and composing views. Ripple doesn't really do anything other than giving you a nice way to compose views inside of each other, add bindings, and use interpolation.

I'm aiming for it to be more like React, where you can compose views and data flows in one direction. This means I could create a TodoList view, and render it inside other views using a custom element.

View.compose('TodoList', TodoList);
<TodoList items="{{ todos }}"></TodoList>

Data from parent can change and update this view. So whenever the parent views todos property changes, it updates the TodoList, sort of like child.set('todos', newTodos);

So it doesn't take your model and wrap it in an adapter like Reactive, instead it uses plain objects and watches them for changes.

I'm still figuring out how data should be passed around, how model interaction works, and if things like computed properties are needed. It's really difficult. So I'm toying with various examples and projects to find something that works.

anthonyshort commented 10 years ago

That said, it's attribute bindings are exactly the same as Reactive, they get used as plugins and they aren't included by default.

matthewmueller commented 10 years ago

Ah interesting thanks for the detailed response.

Have you tried just using JSON structures with object.observe for your models? it seems like that might be the best approach to support both ORM and plain JSON.

matthewmueller commented 10 years ago

oops i missed the last part hahaha

anthonyshort commented 10 years ago

Yeah they're just plain JSON-able objects for models that get wrapped in this https://github.com/ripplejs/model so I can watch it for changes.

Ideally we'll be able to remove set and use Object.observe at some point.