/// <see cref="IStore.AddMiddleware(IMiddleware)"/> public 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) { middleware.Initialize(this); middleware.AfterInitializeAllMiddlewares(); } }
/// <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(); } }); } } }