angular-store
  • @angular/store
  • State
  • Reducer
  • Action
  • Dipatch
  • Selector
  • MISCELLANEOUS
    • Methods
Powered by GitBook
On this page

Dipatch

Dispatch will pass some data to Action when it matches type;

 import { Store } from 'angular-store';
 
// in some compoenent
constructor(private store: Store) {
 this.store.dispatch({ type: 'username', payload: '@angular/store'});
}

// in reducer class
@Action('username') // this action will receive payload "@angular/store"
public onUsernameChange(payload: string, state: IState): void {
  const newData = `${payload}_${new Date()}`;
  const currentState = state.getState();
  state.updateState({ key: username.key, payload: newData });
}

PreviousActionNextSelector

Last updated 6 years ago