4 ms·
SmartReactives: a .NET library that detects when an expression changes its value
- maxxxxx 10y agoThis 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.
- steenreem 10y agoThanks. Yes you can use it to help with INotifyPropertyChanged. The example 'SmartNotifyPropertyChanged' demonstrates one way to do this.
- primigenus 10y agoThis looks similar to how Meteor's ReactiveVar package, and lower-level Tracker library, works: https://docs.meteor.com/api/reactive-var.html https://docs.meteor.com/api/reactive-var.html 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.
- steenreem 10y agoYes Meteor's reactive system seems to be almost identical. Thanks for sharing.
- sandGorgon 10y agoDoes anyone know if you can do this in reactjs? It would be awesome to build a excel like spreadsheet with user-input formulas.
- danthejam 10y agoAs another poster said, you can use Meteor's Tracker and ReactiveVar modules to do it. Here's a standalone package that doesn't require the Meteor platform: https://www.npmjs.com/package/meteor-standalone-tracker https://www.npmjs.com/package/meteor-standalone-tracker
- untog 10y agoWouldn'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.
- sandGorgon 10y agoactually - 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.
- nunyabuizness 10y agoCheck out MobX, as it comes with React bindings to re-render components when their reactive dependencies change: https://github.com/mobxjs/mobx https://github.com/mobxjs/mobx
- goldenkey 10y agoCheck out https://www.npmjs.com/package/watchjs https://www.npmjs.com/package/watchjs
- egeozcan 10y agoThere is Baobab[1] - it is a single state-tree approach, while supporting computed values in the tree and has a react adapter[2]. [1]: https://github.com/Yomguithereal/baobab#computed-data-or-monkey-business https://github.com/Yomguithereal/baobab#computed-data-or-mon... [2]: https://github.com/Yomguithereal/baobab-react https://github.com/Yomguithereal/baobab-react
- deleted 10y ago[deleted]
- sharpercoder 10y agoWhy use this instead of or with Rx.NET?
- danbruc 10y agoThere 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. [1] http://clinq.codeplex.com http://clinq.codeplex.com [2] https://github.com/ismell/Continuous-LINQ https://github.com/ismell/Continuous-LINQ [3] https://bindablelinq.codeplex.com https://bindablelinq.codeplex.com [4] http://obtics.codeplex.com http://obtics.codeplex.com [5] https://github.com/wasabii/OLinq https://github.com/wasabii/OLinq [6] https://msdn.microsoft.com/en-us/data/gg577609.aspx https://msdn.microsoft.com/en-us/data/gg577609.aspx [7] https://github.com/Reactive-Extensions/Rx.NET https://github.com/Reactive-Extensions/Rx.NET
- UK-AL 10y agoRx.net is probably the most well used one.
- m_fayer 10y agoThere 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 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.
- tabulatouch 10y agoI like componentized functionalities a lot, and i think .NET shines for that.
- steenreem 10y agoThis 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.
- nunyabuizness 10y agoIf 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. [1] https://github.com/mobxjs/mobx https://github.com/mobxjs/mobx
- polskibus 10y agoI wonder how does this compare to Jane's Street Incremental library?
- steenreem 10y agoMy 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.
- newtype 10y agoI wrote something that does this too! I'm looking forward to seeing the differences in our implementations :D
- steenreem 10y agoAlright. Where can I find your project? You can let me know in Gitter or e-mail.