示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
 /// <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));
 }