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
import { AppState } from '../../states'; | |
export const selectPost = (state: AppState) => state.postState.data; | |
export const selectPosts = (state: AppState) => state.postState.posts; |
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
import { AppState } from '../../states'; | |
export const selectUsers = (state: AppState) => state.userState.users; | |
export const selectUser = (state: AppState) => state.userState.data; |
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
import { PostState } from '../post'; | |
import { UserState } from '../user'; | |
export interface AppState { | |
userState: UserState; | |
postState: PostState; | |
} |
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
import { Injectable } from '@angular/core'; | |
import { Actions, Effect, ofType } from '@ngrx/effects'; | |
import { Store, select } from '@ngrx/store'; | |
import { switchMap, map, withLatestFrom } from 'rxjs/operators'; | |
import { of } from 'rxjs'; | |
import { LoadPostAction, LoadPostsAction, LoadPostActionPing, LoadPostsActionPing, PostActionTypes } from '../../actions'; | |
import { AppState } from '../../states'; | |
import { selectPosts } from '../../selectors'; | |
import { PostService } from '../../../services'; |
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
import { Injectable } from '@angular/core'; | |
import { Actions, Effect, ofType } from '@ngrx/effects'; | |
import { Store, select } from '@ngrx/store'; | |
import { of } from 'rxjs'; | |
import { switchMap, withLatestFrom, map } from 'rxjs/operators'; | |
import { LoadUserAction, LoadUsersAction, LoadUserActionPing, LoadUsersActionPing, UserActionTypes } from '../../actions'; | |
import { AppState } from '../../states'; | |
import { UserService } from '../../../services'; | |
import { selectUsers } from '../../selectors'; |
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
import { PostState, initialPostState } from '../../states'; | |
import { PostActionTypes, PostActionUnion } from '../../actions'; | |
export default (state: PostState = initialPostState, action: PostActionUnion) : PostState => { | |
switch (action.type) { | |
case PostActionTypes.LoadPost: | |
return { | |
...state, | |
data: action.payload.data | |
}; |
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
import { UserState, initialUserState } from '../../states'; | |
import { UserActionTypes, UserActionUnion } from '../../actions'; | |
export default (state: UserState = initialUserState, action: UserActionUnion) : UserState => { | |
switch (action.type) { | |
case UserActionTypes.LoadUser: | |
return { | |
...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
import { Action } from '@ngrx/store'; | |
import { Post } from '../../../models'; | |
export enum PostActionTypes { | |
LoadPostPing = '[Post] Ping To Load A Post', | |
LoadPostsPing = '[Post] Ping To Load All Posts', | |
LoadPost = '[Post] Load A Post', | |
LoadPosts = '[Post] Load All Posts' | |
} |
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
import { Action } from '@ngrx/store'; | |
import { User } from '../../../models'; | |
export enum UserActionTypes { | |
LoadUserPing = '[User] Ping To Load User', | |
LoadUsersPing = '[User] Ping To Load Users', | |
LoadUser = '[User] Load A User', | |
LoadUsers = '[User] Load All Users' | |
} |
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
import { Injectable } from '@angular/core'; | |
import { Post, User } from '../../models'; | |
let id: number = 1; | |
@Injectable() | |
export class PostService { | |
public db: Post[] = []; | |
constructor() {} |