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 { | |
Component, | |
Input, | |
OnChanges, | |
SimpleChanges, | |
OnDestroy, | |
} from '@angular/core'; | |
import { | |
MatDialogRef, | |
MatDialogConfig, |
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 { CommonModule, NgClass } from '@angular/common'; | |
import { Component } from '@angular/core'; | |
import { UntilDestroy } from '@ngneat/until-destroy'; | |
import { concat, timer } from 'rxjs'; | |
import { delay, map, repeat, startWith, takeWhile, tap } from 'rxjs/operators'; | |
@UntilDestroy() | |
@Component({ | |
selector: 't-logo', | |
standalone: true, |
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
requireUsers$ = this.userSelectors.needUsers$.pipe( | |
filter(needUsers => needUsers), | |
tap(() => this.store.dispatch({type: 'GET_USERS'})), | |
switchMap(() => this.getUsers()), | |
tap(users => this.store.dispatch({type: 'RECEIVE_USERS', users})), | |
share(), | |
); | |
users$ = using( | |
() => this.requireUsers$.subscribe(), |
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
requireUsers$ = this.userSelectors.needUsers$.pipe( | |
filter(needUsers => needUsers), | |
tap(() => this.store.dispatch({type: 'GET_USERS'})), | |
switchMap(() => this.getUsers()), | |
tap(users => this.store.dispatch({type: 'RECEIVE_USERS', users})), | |
finalize(() => this.store.dispatch({type: 'CANCEL_GET_USERS'})), | |
share(), | |
); | |
users$ = using( |
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
@Effect() actionX$ = this.updates$.pipe( | |
ofType('ACTION_X'), | |
map(toPayload), | |
switchMap(payload => this.api.callApiX(payload).pipe( | |
map(data => ({type: 'ACTION_X_SUCCESS', payload: data})), | |
catch(err => Observable.of({type: 'ACTION_X_FAIL', payload: err})), | |
)), | |
); | |
@Effect() actionY$ = this.updates$.pipe( | |
ofType('ACTION_Y'), |
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
@Effect getUsers$ = this.actions$.pipe( | |
ofType('GET_USERS', 'CANCEL_GET_USERS'), | |
withLatestFrom(this.userSelectors.needUsers$), | |
filter(([action, needUsers]) => needUsers), | |
map(([action, needUsers]) => action), | |
switchMap(action => action.type === 'CANCEL_GET_USERS' ? | |
Observable.of() : | |
this.getUsers().pipe( | |
map(users => ({type: 'RECEIVE_USERS', 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
@Effect getUsers$ = this.actions$.pipe( | |
ofType('GET_USERS'), | |
withLatestFrom(this.userSelectors.needUsers$), | |
filter(([action, needUsers]) => needUsers), | |
switchMap(() => this.getUsers()), | |
map(users => ({type: 'RECEIVE_USERS', 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
@Effect() this.actions$.pipe( | |
ofType("DELETE_ITEM_SUCCESS"), | |
map(() => ({type: "REMOVE_FAVORITE_ITEM_ID"})), | |
); |
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
audioPlaying$ = this.store.select('audioPlaying'); | |
videoPlaying$ = this.store.select('videoPlaying'); | |
mediaPlaying$ = combineLatest([ | |
this.audioPlaying$, | |
this.videoPlaying$, | |
]).pipe( | |
map(([audioPlaying, videoPlaying]) => audioPlaying || videoPlaying, | |
); |
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
@Effect() playMediaWithAudio$ = this.actions$.pipe( | |
ofType("PLAY_AUDIO"), | |
map(() => ({type: "PLAY_MEDIA"})), | |
); |
NewerOlder