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
{ | |
"name": "Net.Core_GraphQL", | |
"version": "0.0.0", | |
"scripts": { | |
"ng": "ng", | |
"start": "ng serve", | |
"build": "ng build", | |
"build:ssr": "ng run Net.Core_GraphQL:server:dev", | |
"test": "ng test", | |
"lint": "ng lint", |
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
//from the reducer | |
//export common use selector for your selector | |
export const { | |
selectAll, | |
selectEntities, | |
selectIds, | |
selectTotal | |
} = adapter.getSelectors(); | |
//from the selector |
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
new userActions.LoadAllUserSuccess({ | |
users: userList // user list data return from API in your effect | |
}) |
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
export class LoadAllUserSuccess implements Action { | |
public readonly type = UserActionTypes.LoadAllUserSuccess; | |
constructor(public payload: { users: IUser[] }) {} | |
} |
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 { | |
createEntityAdapter, | |
EntityAdapter, | |
EntityState | |
} from "@ngrx/entity"; | |
export interface IUser { | |
id: string; | |
name: string; | |
email: string; |
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
export class UpdateUserEmail implements Action { | |
public readonly type = UserActionTypes.UpdateUserEmail; | |
constructor( | |
public payload: { | |
id: number; | |
email: string; | |
} | |
) {} | |
} |
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
// Pass in 3 to to tell ReplaySubject remember all 3 value | |
let replaySubject = new ReplaySubject<string>(3); | |
replaySubject.next("First value"); | |
replaySubject.next("Second value"); | |
replaySubject.next("Third value"); | |
replaySubject.asObservable().subscribe((data) => { | |
console.log(`Get data from replaySubject ${data}`); | |
}); |
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 { BehaviorSubject } from 'rxjs'; | |
// Behavior subjects need a first value | |
let behaviorSubject = new BehaviorSubject<string>("Some dummy first value"); | |
behaviorSubject.asObservable().subscribe((data) => { | |
console.log(`Get data ${data}`); | |
}); | |
behaviorSubject.next("next value") |
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
private subscription$: Subscription; | |
public ngOnInit(): void { | |
this.subscription$ = this.messageervice | |
.getData() | |
.subscribe(data => { console.log(data); }) | |
} | |
public ngOnDestroy(): void { | |
this.subscription$.unsubscribe(); |
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 { Injectable } from "@angular/core"; | |
import { Subject } from "rxjs"; | |
@Injectable() | |
export class MessageService { | |
private subject = new Subject<any>(); | |
constructor() {} | |
sendMessage(message: any) { |