Example #1
0
        /// <see cref="IStore.AddMiddleware(IMiddleware)"/>
        public async void AddMiddleware(IMiddleware middleware)
        {
            Middlewares.Add(middleware);
            ReversedMiddlewares.Insert(0, middleware);
            // Initialize the middleware immediately if the store has already been initialized, otherwise this will be
            // done the first time Dispatch is called
            if (HasActivatedStore)
            {
                await middleware.InitializeAsync(this);

                middleware.AfterInitializeAllMiddlewares();
            }
        }
Example #2
0
 /// <see cref="IStore.AddMiddleware(IMiddleware)"/>
 public void AddMiddleware(IMiddleware middleware)
 {
     lock (SyncRoot)
     {
         Middlewares.Add(middleware);
         ReversedMiddlewares.Insert(0, middleware);
         // Initialize the middleware immediately if the store has already been initialized, otherwise this will be
         // done the first time Dispatch is called
         if (HasActivatedStore)
         {
             middleware
             .InitializeAsync(this)
             .ContinueWith(t =>
             {
                 if (t.IsCompletedSuccessfully)
                 {
                     middleware.AfterInitializeAllMiddlewares();
                 }
             });
         }
     }
 }