Meta Reducers
import { getActionTypeFromInstance } from '@ngxs/store';
export function logoutPlugin(state, action, next) {
// Use the get action type helper to determine the type
if (getActionTypeFromInstance(action) === Logout.type) {
// if we are a logout type, lets erase all the state
state = {};
}
// return the next function with the empty state
return next(state, action);
}import { NgModule } from '@angular/core';
import { NGXS_PLUGINS } from '@ngxs/store';
@NgModule({
imports: [NgxsModule.forRoot([])],
providers: {
{
provide: NGXS_PLUGINS,
useValue: logoutPlugin,
multi: true
}
}
})
export class AppModule {}Last updated

