Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Last active October 14, 2022 18:30
Show Gist options
  • Save ajcrites/89550299f0a35673e8c316ddeaf03e01 to your computer and use it in GitHub Desktop.
Save ajcrites/89550299f0a35673e8c316ddeaf03e01 to your computer and use it in GitHub Desktop.
export class ProfilePage {
...
shouldTriggerAppOpen = false;
gameUrl = from(this.userService.getUserId()).pipe(
mergeMap(
({ token: userIdToken } = { token = '' }) =>
this.gameService.buildUrl(userIdToken)
),
tap(url => {
Browser.open(url);
this.shouldTriggerAppOpen = false;
}),
);
gameUrlHasError = this.gameUrl.catchError(
gameUrlError => of(gameUrlError),
);
}
<a (click)="shouldTriggerAppOpen = true">
Open The Game
</a>
<ng-container *ngIf="shouldTriggerAppOpen">
<ng-container *ngIf="gameUrl | async; else loadingOrError"></ng-container>
</ng-container>
<ng-template #loadingOrError>
<error-message
*ngIf="gameUrlHasError as error | async; else loading"
[message]="error.message"
></error-message>
</ng-template>
<ng-template #loading>
<loading-toast></loading-toast>
</ng-template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment