Not accessing the changed property doesn't call observe second time
See original GitHub issue.observe()
callback is not called if the changed property getter is not executed in the .observe()
callback. Take a look at the example below. Execute it then try uncommenting the line and commenting the one above.
const observer = require('@risingstack/nx-observe');
const observable = observer.observable();
// This way doesn't call the callback twice
observer.observe(() => console.log(observable));
// This way works
// observer.observe(() => console.log(observable.value));
observable.value = 3;
setTimeout(() => observable.value = 4);
Issue Analytics
- State:
- Created 7 years ago
- Comments:18 (10 by maintainers)
Top Results From Across the Web
LiveData Observer isn't triggered for the second time
The currentData one gets any new values posted to this new source, and the fragment only has to observe that single LiveData once....
Read more >LiveData overview - Android Developers
The setValue(T) method updates the value of the LiveData instance and notifies any active observers about the change.
Read more >How to Observe Property Changes with LitElement and ...
You can use the changedProperties.has("<propName>") to find out if your property has been changed or not. If your property has been changed, ...
Read more >Sharing your Netflix account - Netflix Help Center
A Netflix account is for people who live together in a single household. Sharing Netflix with someone who doesn't live with you. People...
Read more >3 Known Issues and Workarounds - Oracle Help Center
Use either of the following workarounds to bypass the new password restrictions. Set the BACKWARD_COMPAT_PW_CHECK environment variable to true .
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
Going to also add some basic benchmarks (nx-observe vs vanilla js for now). I guess it might be interesting for you too. (Right now I only have benchmarks for the whole nx-framework together)
Just to clarify: instead of binding on observable properties once, nx-observe looks for yet unregistered parts of the function (hidden by conditionals or loops) on every run and binds on the newly revealed properties.