示例#1
0
文件: Store.cs 项目: gdar91/RxStore
        public Store(TState initialState, Func <TState, TEvent, TState> reducer)
        {
            var initialStateTransition = StateTransition.NewInitial(initialState);

            StateTransitions =
                Events
                .Scan(initialStateTransition, StateTransition.LiftReducer(reducer))
                .StartWith(initialStateTransition)
                .Publish()
                .AutoConnect();

            States =
                StateTransitions
                .Select(StateTransition.StateOf)
                .DistinctUntilChanged()
                .Replay(1)
                .AutoConnect(0);
        }