示例#1
0
        private Enhancer _CreateEnhancer(Middleware.DelegateMiddleware[] middlewares)
        {
            return((createStore) => (store, enhancer) =>
            {
                createStore(store);
                if (middlewares == null || middlewares.Length == 0)
                {
                    return;
                }

                var _dispatch = store.Dispatch;
                var chain = new Compose.DelegateComposedDispatch[middlewares.Length];

                var middlewareAPI = new Middleware.MiddlewareAPI()
                {
                    GetStories = store.GetStories,
                    Dispatch = (action) => {
                        return _dispatch(action);
                    }
                };

                for (var i = 0; i < middlewares.Length; ++i)
                {
                    chain[i] = middlewares[i](middlewareAPI);
                }
                _dispatch = Compose.ComposeDispatches(chain)(store.Dispatch);
                store.Dispatch = _dispatch;
            });
        }
示例#2
0
        private EnhancerCreator.Enhancer GetComposedEnhancers()
        {
            if (enhancerCreators == null || enhancerCreators.Length == 0)
            {
                return(null);
            }

            var enhancers = new EnhancerCreator.Enhancer[enhancerCreators.Length];

            for (var i = 0; i < enhancerCreators.Length; ++i)
            {
                enhancers[i] = enhancerCreators[i].CreateEnhancer();
            }

            return(Compose.ComposeEnhancers(enhancers));
        }