Last active
June 1, 2018 02:33
-
-
Save glendaviesnz/d398bee1c69dad8fab00494a1935bf58 to your computer and use it in GitHub Desktop.
Extension of NgRx ActionsSubject to manage Component State
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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