This file contains hidden or 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 UsersEffect { | |
constructor( | |
private actions$: Actions, | |
private usersService: UsersService | |
) {} | |
@Effect() | |
loadUsers$ = this.actions$ | |
.ofType(usersActions.LOAD_USERS) |
This file contains hidden or 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
import { Store } from '@ngrx/store'; | |
import * as fromStore from '../../store'; | |
export class MyComponent(){ | |
constructor(private store: Store<fromStore.UsersState>) { } | |
loadUsers(){ | |
this.store.dispatch(new fromStore.LoadUsers()); | |
} | |
} |
This file contains hidden or 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
import * as fromUsers from '../actions/users.action'; | |
import { Users } from 'resources/users/users'; | |
export interface UsersState { | |
entities: Users.Entities; | |
loaded: boolean, | |
loading: boolean | |
} | |
export const initialState: UsersState = { |
This file contains hidden or 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
import { Action } from '@ngrx/store'; | |
export const LOAD_USERS = '[Users] Load Users'; // It's good practice to add namespace for each action module | |
export const LOAD_USERS_FAIL = '[Users] Load Users Fail'; | |
export const LOAD_USERS_SUCCESS = '[Users] Load Users Success'; | |
export class LoadUsers implements Action { | |
readonly type = LOAD_USERS; | |
} | |
NewerOlder