You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No, there is no way get the previous value of an atom. Alternatively, you can write reaction that remembers the previous value.
privatevoidStart(){
Reaction(()=> Counter,(current,previous)=> Debug.Log($"Counter changed from {previous} to {current}"));}privatestatic Reaction Reaction<T>(AtomPull<T>reaction,Action<T,T>effect){varhasPrevious=false;varprevious=default(T);return Atom.Reaction(reaction,value =>{if(hasPrevious){ effect(value, previous);}previous=value;hasPrevious=true;});}
Thanks! Btw, I want to use it to find the difference of 2 collections so that the view layer could efficiently update it's contents. I am trying to replace UniRx-based view models with [Atom]-based.
Hey, Is there a way to get previous value of an [Atom] property inside of Reaction?
The text was updated successfully, but these errors were encountered: