예제 #1
0
        public static SubListeners <S> NewSubStateListener <T, S>(this SubListeners <T> self, Func <T, S> getSubState)
        {
            var subListener = new SubListeners <S>(getSubState(self.latestSubState));

            self.AddStateChangeListener(getSubState, newSubState => { subListener.OnSubstateChanged(newSubState); });
            return(subListener);
        }
예제 #2
0
        public static SubListeners <S> NewSubStateListener <T, S>(this SubListeners <T> self, Func <T, S> getSubState)
        {
            var subListener         = new SubListeners <S>(getSubState(self.latestSubState));
            var ownListenerInParent = self.AddStateChangeListener(getSubState, newSubState => { subListener.OnSubstateChanged(newSubState); });

            subListener.SetUnregisterInParentAction(() => { self.innerListeners -= ownListenerInParent; });
            return(subListener);
        }