This is neat. I did something similar to this a while ago for WPF databinding and calculated properties in business objects. Does it support INotifyPropertyChanged?
One of the problems I found is that a lot of team members don't really like to think on that level of abstraction. So it was hard to introduce it team wide and have people keep using it.
It's certainly helped make building real-time user interfaces that update when the data changes significantly easier in my opinion, because you're able to express your intent in code more closely to what you mean rather than having to write all the connecting reactive boilerplate yourself.
Wouldn't it be backwards to do this in React? Everything is controlled by a state object you manually set, so you already know when values are going to change.
actually - I'm talking about a function expression. Think about a spreadsheet with a formula similar to "=SUM(A1+B1)". What this means is that when A1 or B1 change.. then this formula result should get re-computed. Remember that A1 and B1 themselves may be computed results...
what happens today is that I need to recompute ALL formulas - because there is no easy way to know which formulas changed.
There are also Continuous LINQ [1][2], Bindable LINQ [3], Obtics [4] and OLinq [5], some predating Rx [6][7]. Besides OLinq they all seem no longer maintained but in case somebody is interested in other existing implementations, there you go. Also note that they don't all solve the exact same but similar problems.
There are many application-specific scenarios that are enabled by RX that would still take quite a bit of hand-rolling a deep knowledge of RX to get right.
A favorite of mine right now is https://github.com/RolandPheasant/DynamicData which I use for easily "deriving" from in-memory collections to create new collections that are actually "live views" onto the source collection. Makes things like mapping, sorting, filtering, paging, and so on super-simple while letting you avoid creating unnecessary state.
This is not a replacement for Rx, actually it relies on Rx. SmartReactives is an addition to Rx which allows you to get an IObservable from an expression for free, while with just Rx you'd have to instrument your expression.
If you're using JavaScript, MobX [1] is a library available that implements this pattern, which I find a bit easier to use than Meteor's Tracker yet also comes with super-performant React bindings.
My perception is that there's almost no overlap in scope between the two libraries. In Incremental you have to be explicit about which variables your computations depends on, while SmartReactives' sole purpose is discovering these dependencies automatically. SmartReactives discovers dependencies as a side-effect of evaluating variables while evaluating expressions. OCaml on the other hand is a mostly pure language so side-effects are not allowed.
Incremental on the other hand does cool stuff like use the result of the first computation to make the second computation faster, which SmartReactives does not do at all.
So I'd say although the projects are related they don't overlap in scope.
24 comments
[ 3.5 ms ] story [ 63.0 ms ] threadOne of the problems I found is that a lot of team members don't really like to think on that level of abstraction. So it was hard to introduce it team wide and have people keep using it.
It's certainly helped make building real-time user interfaces that update when the data changes significantly easier in my opinion, because you're able to express your intent in code more closely to what you mean rather than having to write all the connecting reactive boilerplate yourself.
what happens today is that I need to recompute ALL formulas - because there is no easy way to know which formulas changed.
[1]: https://github.com/Yomguithereal/baobab#computed-data-or-mon...
[2]: https://github.com/Yomguithereal/baobab-react
https://github.com/Reactive-Extensions/RxJS
[1] http://clinq.codeplex.com [2] https://github.com/ismell/Continuous-LINQ [3] https://bindablelinq.codeplex.com [4] http://obtics.codeplex.com [5] https://github.com/wasabii/OLinq [6] https://msdn.microsoft.com/en-us/data/gg577609.aspx [7] https://github.com/Reactive-Extensions/Rx.NET
A favorite of mine right now is https://github.com/RolandPheasant/DynamicData which I use for easily "deriving" from in-memory collections to create new collections that are actually "live views" onto the source collection. Makes things like mapping, sorting, filtering, paging, and so on super-simple while letting you avoid creating unnecessary state.
[1] https://github.com/mobxjs/mobx
Incremental on the other hand does cool stuff like use the result of the first computation to make the second computation faster, which SmartReactives does not do at all.
So I'd say although the projects are related they don't overlap in scope.