Closed SDSLeon closed 7 years ago
And if i write autorun function where i will also use this computed. All things back to normal and computed will be called only once.
http://prntscr.com/e9uutf with use co,puted values in autorun http://prntscr.com/e9uv6o without
The problem exist if use *mobxAutorun with autorunAsync.
With *mobxAutorunSync and autorun computed called only once on update, but still called twice on Init.
this.autoDetect(this.view); Need to be moved to constructor for autoruns directives. But stay in Init method for reaction.
This will fix the double computed runs on init
I moved createEmbeddedView
and autoDetect
to ngOnInit
,
and not using autorunAsync anymore.
Seems like it's solving the problem, so I'll also deprecate autorunSync directive.
Fixed in 1.2.8 and published - can you verify?
Thanks! Fixed twice run on change observable value.
Still runs twice on first run after F5. http://prntscr.com/ec8utz
I think autoDetect
should be called before ngOnInit
to be applied for first run.
When I tried it it ran only once
Can you share your code? Maybe you're calling the computed value outside the autorun? Or you're changing an observable?
yeah! you are right, i recheck the code and find the observable value that changed.
So, its fully fixed. =) Thanks.
awesome
I am try the Todo example from this project and see that computed functions in mobx store is called twice every time when one 1 observable change.
http://prntscr.com/e9omwg
Is this a normal?
Also i see this in my own project.
If i remove *mobxAutorun it will be called only once. Example and my own app still works. http://prntscr.com/e9oois But now function is called every time i type in input. http://prntscr.com/e9opxs