Skip to content

Instantly share code, notes, and snippets.

@ova2
Last active April 3, 2019 06:41
Show Gist options
  • Save ova2/c15c7df399ebf9cb5cd2c3d553421084 to your computer and use it in GitHub Desktop.
Save ova2/c15c7df399ebf9cb5cd2c3d553421084 to your computer and use it in GitHub Desktop.
@Injectable({
providedIn: 'root'
})
export class CoreFacade {
public isLoggedIn$ = this._store.select((state: CoreState) => !!state.authToken);
constructor(private _store: CoreStore, private _loginService: LoginService) { }
public getTrackNumber(): string {
return this._store.state.trackNumber;
}
public generateDeviceId(): void {
// generate Device-Id just once
this._store.readDeviceId().then(deviceId => {
if (!deviceId) {
this._store.setDeviceId(UUID.next().value)
.finally(() => console.log('Device-Id has been generated'));
}
});
}
public identifyDevice(trackNumber: string): Observable<boolean> {
const stream$ = forkJoin([
...
this._store.setTrackNumber(trackNumber)
]
).pipe(
switchMap(_ => _loginService.identifyDevice(trackNumber)),
);
return stream$;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment