public static Action AddStateChangeListener <T, S>(this IDataStore <T> self, S mutableObj, Action <S> onChanged, bool triggerInstantToInit = true) where S : IsMutable { Action newListener = () => { if (StateCompare.WasModifiedInLastDispatch(mutableObj)) { onChanged(mutableObj); } }; self.onStateChanged += newListener; if (triggerInstantToInit) { onChanged(mutableObj); } return(newListener); }
public Action AddStateChangeListener <T, S>(S mutableObj, Action <S> onChanged, bool triggerInstantToInit = true) where S : IsMutable { Action newListener = () => { if (StateCompare.WasModifiedInLastDispatch(mutableObj)) { onChanged(mutableObj); } }; innerListeners += newListener; if (triggerInstantToInit) { onChanged(mutableObj); } return(newListener); }
/// <summary> Will be true if the object was modified when the last mutation was /// dispatched via the data store the object is managed in </summary> public static bool WasModifiedInLastDispatch(this IsMutable self) { return(StateCompare.WasModifiedInLastDispatch(self)); }