[Optimization] Don't trigger observers if prev value and new value are same
See original GitHub issueFor this snippet -
const observer = require("@risingstack/nx-observe");
let context = observer.observable({"name" : "a"});
const signal = observer.observe(()=>console.log(context.name));
let name = context.name;
context.name = "a";
The observer is triggered twice. Wouldn’t it help to not trigger observers if the value hasn’t changed?
Issue Analytics
- State:
- Created 7 years ago
- Comments:45 (23 by maintainers)
Top Results From Across the Web
LiveData prevent receive the last value when start observing
I don't think it is possible to prevent LiveData from receiving the last value when start observing if you are using them as...
Read more >Observers and computed properties - Polymer Project
Observers do not receive old values as arguments, only new values. Only single-property observers defined in the properties object receive both old and...
Read more >Swift Property Observers - NSHipster
When you declare a stored property, you have the option to define property observers with blocks of code to be executed when a...
Read more >RxJS: Observables, Observers and Operators Introduction
When an Observable produces values, it then informs the observer, calling .next() when a new value was successfully captured and .error() ...
Read more >The 10 most used observables operators - Christian Lüdemann
When observers register the ReplaySubject will “replay” previous values to ... are arrays/steams of data, a lot of the Observable operators work the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
nx-observe 3.0.0 is published. It comes with all of the improvements mentioned above.
The examples you mentioned above has the following result with v3.0.0.
1, code:
output:
2, code:
output:
@ippa So far the integration has been good 😃, @solkimicreb has been very helpful and has helped us a lot by fixing issues that came along the way. The implementation is very much like with mobx and design considerations are also similar. The project is not open source yet and I have been working on other challenges with it. But I will try to share a simple example soon on the discussion which @solkimicreb spun from this.