Skip to content

Instantly share code, notes, and snippets.

@glendaviesnz
Last active June 1, 2018 02:33
Show Gist options
  • Save glendaviesnz/d398bee1c69dad8fab00494a1935bf58 to your computer and use it in GitHub Desktop.
Save glendaviesnz/d398bee1c69dad8fab00494a1935bf58 to your computer and use it in GitHub Desktop.
Extension of NgRx ActionsSubject to manage Component State
@Injectable()
export class ComponentStateMachine extends ActionsSubject {
constructor() {
super();
}
public next(action: any) {
// add all your state machine magic here ....
if (isValidAction) {
super.next(action);
}
}
}
// then in the module providers section just add
{ provide: ActionsSubject, useClass: ComponentStateMachine }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment