|
3 | 3 | * or more contributor license agreements. Licensed under the Elastic License; |
4 | 4 | * you may not use this file except in compliance with the Elastic License. |
5 | 5 | */ |
6 | | -import { Observable, Subscription } from 'rxjs'; |
7 | | -import { ILicense } from '../../../../../licensing/public'; |
8 | | -import { useSetupDeps } from './use_deps'; |
| 6 | +import { LicenseService } from '../services'; |
9 | 7 |
|
10 | | -// TODO: Make this better lol |
11 | | -class LicenseService { |
12 | | - private observable: Observable<ILicense> | null = null; |
13 | | - private subscription: Subscription | null = null; |
14 | | - private licenseInformation: ILicense | null = null; |
15 | | - |
16 | | - private updateInformation(licenseInformation: ILicense) { |
17 | | - this.licenseInformation = licenseInformation; |
18 | | - } |
19 | | - |
20 | | - public start(license$: Observable<ILicense>) { |
21 | | - this.observable = license$; |
22 | | - this.subscription = this.observable.subscribe(this.updateInformation.bind(this)); |
23 | | - } |
24 | | - |
25 | | - public stop() { |
26 | | - if (this.subscription) { |
27 | | - this.subscription.unsubscribe(); |
28 | | - } |
29 | | - } |
30 | | - |
31 | | - public getLicenseInformation() { |
32 | | - return this.licenseInformation; |
33 | | - } |
34 | | - |
35 | | - public getLicenseInformation$() { |
36 | | - return this.observable; |
37 | | - } |
38 | | -} |
| 8 | +export const licenseService = new LicenseService(); |
39 | 9 |
|
40 | 10 | export function useLicense() { |
41 | | - const { licensing } = useSetupDeps(); |
42 | | - const licenseService = new LicenseService(); |
43 | | - licenseService.start(licensing.license$); |
44 | 11 | return licenseService; |
45 | 12 | } |
0 commit comments