-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@cubejs-client/ngx): async CubejsClient initialization (#2876)
- Loading branch information
1 parent
ce6b317
commit bba3a01
Showing
11 changed files
with
1,106 additions
and
961 deletions.
There are no files selected for viewing
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
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
33 changes: 33 additions & 0 deletions
33
examples/dynamic-angular-dashboard/src/app/auth.service.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { BehaviorSubject, from } from 'rxjs'; | ||
import { CubejsConfig } from '@cubejs-client/ngx'; | ||
|
||
import { cubejsConfig } from './app.module'; | ||
|
||
@Injectable() | ||
export class AuthService { | ||
public config$ = new BehaviorSubject<CubejsConfig | null>(null); | ||
|
||
constructor() { | ||
this.login().then(() => console.log('config ready')); | ||
} | ||
|
||
// Used as an example to show async CubejsClient initialization | ||
public login(): any { | ||
return new Promise<void>((resolve) => | ||
setTimeout(() => { | ||
this.config$.next({ | ||
token: cubejsConfig.token, | ||
options: { | ||
apiUrl: cubejsConfig.options.apiUrl, | ||
}, | ||
}); | ||
resolve(); | ||
}, 0) | ||
); | ||
} | ||
|
||
public logout(): void { | ||
this.config$.next(null); | ||
} | ||
} |
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
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
Oops, something went wrong.