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
| this.store.select('games').pipe(untilDestroyed(this)).subscribe((res: IGames) => {}); |
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 { Observable, Subject } from 'rxjs'; | |
| import { takeUntil } from 'rxjs/operators'; | |
| function isFunction(value) { | |
| return typeof value === 'function'; | |
| } | |
| export const untilDestroyed = ( | |
| componentInstance, | |
| destroyMethodName = 'ngOnDestroy' |
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
| forkJoin( | |
| this._myService.makeRequest('Request One', 2000), | |
| this._myService.makeRequest('Request Two', 1000), | |
| this._myService.makeRequest('Request Three', 3000) | |
| ) | |
| .subscribe(([res1, res2, res3]) => { | |
| this.propOne = res1; | |
| this.propTwo = res2; | |
| this.propThree = res3; | |
| }); |
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 { Observable } from 'rxjs/Observable'; | |
| import { | |
| environment as env | |
| } from '../../../environments/environment'; | |
| import { Effect, ofType, Actions } from '@ngrx/effects'; | |
| import { Action } from '@ngrx/store'; | |
| import { switchMap } from 'rxjs/operators'; | |
| import { of, forkJoin } from 'rxjs'; | |
| import { catchError } from 'rxjs/internal/operators'; |
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
| @Effect() | |
| getGames: Observable<Action> = this.actions$.pipe( | |
| ofType(GamesActions.GET_GAMES_REQUESTED), | |
| switchMap(() => { | |
| return forkJoin(this.http | |
| .get(`${env.apiURL}/games?locale=${regionConfig.locale}`), this.http | |
| .get(`${env.apiURL}/games/catalogues/${regionConfig.locale}`)) | |
| .defaultIfEmpty([]) | |
| .map(results => of(new GetGamesFailure(results))) | |
| .subscribe(console.log); |
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
| @Effect({ dispatch: false }) | |
| getUser: Observable<Action> = this.actions$.pipe( | |
| ofType(UserActionTypes.userGetAccount), | |
| mergeMap((value: GetAccountAction) => { | |
| const key: StateKey<number> = makeStateKey<number>('userData'); | |
| const data: UserData = this.transferState.get(key, null); | |
| if (data) { | |
| return Observable.of(new UpdateUserSuccess(data)); | |
| } else { | |
| this.auth.validateUser().pipe( |
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
| ... | |
| changePosValue(pos) { | |
| this.onStartSlideshow(); | |
| this.cPos = pos; | |
| } | |
| ... |
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
| xp-slide(*ngFor="let slide of slides", [slide]="slide") | |
| xp-slider-nav([slides]="slides", (changePos)="changePosValue($event)") |
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 SomeChildComponent implements OnChanges { | |
| @Input() save; | |
| ngOnChanges(changes: SimpleChanges) { | |
| if (changes.save && changes.save.currentValue) { | |
| this.onSave(); | |
| } | |
| } | |
| onSave() {...} | |
| } |
NewerOlder