@equinor/fusion-framework-module-app
Advanced tools
Comparing version 2.8.1 to 3.1.0
@@ -6,2 +6,18 @@ # Change Log | ||
## 3.1.0 (2023-01-04) | ||
### Features | ||
- **module-app:** allow clearing current app ([c7f4c14](https://github.com/equinor/fusion-framework/commit/c7f4c144c29c2c40df42eafcdaabfb8214e1e88d)) | ||
## 3.0.0 (2023-01-04) | ||
### ⚠ BREAKING CHANGES | ||
- **module-app:** manifest prop rename | ||
### Bug Fixes | ||
- **module-app:** rename `appKey` to `key` ([9ee97b1](https://github.com/equinor/fusion-framework/commit/9ee97b149b9167a3747da371de76490e287d9514)) | ||
## 2.8.1 (2022-12-21) | ||
@@ -8,0 +24,0 @@ |
@@ -13,3 +13,3 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
var _AppModuleProvider_appsClient, _AppModuleProvider_configClient, _AppModuleProvider_current$, _AppModuleProvider_subscription, _AppModuleProvider_event; | ||
import { BehaviorSubject, catchError, distinctUntilKeyChanged, map, pairwise, Subscription, takeWhile, } from 'rxjs'; | ||
import { BehaviorSubject, catchError, distinctUntilChanged, map, pairwise, Subscription, takeWhile, } from 'rxjs'; | ||
import { HttpResponseError } from '@equinor/fusion-framework-module-http'; | ||
@@ -27,3 +27,8 @@ import { Query } from '@equinor/fusion-query'; | ||
get current$() { | ||
return __classPrivateFieldGet(this, _AppModuleProvider_current$, "f").pipe(filterEmpty(), distinctUntilKeyChanged('appKey')); | ||
return __classPrivateFieldGet(this, _AppModuleProvider_current$, "f").pipe(distinctUntilChanged((prev, next) => { | ||
if (prev && next) { | ||
return prev.appKey === next.appKey; | ||
} | ||
return prev === next; | ||
})); | ||
} | ||
@@ -88,2 +93,5 @@ constructor(args) { | ||
} | ||
clearCurrentApp() { | ||
__classPrivateFieldGet(this, _AppModuleProvider_current$, "f").next(null); | ||
} | ||
createApp(value) { | ||
@@ -90,0 +98,0 @@ return new App(value, { provider: this, event: __classPrivateFieldGet(this, _AppModuleProvider_event, "f") }); |
@@ -5,3 +5,3 @@ import { Observable } from 'rxjs'; | ||
import { Query } from '@equinor/fusion-query'; | ||
import type { AppConfig, AppManifest } from './types'; | ||
import type { AppConfig, AppManifest, CurrentApp } from './types'; | ||
import { App } from './app/App'; | ||
@@ -16,4 +16,4 @@ import { AppModuleConfig } from './AppConfigurator'; | ||
}>; | ||
get current(): App | undefined; | ||
get current$(): Observable<App>; | ||
get current(): CurrentApp; | ||
get current$(): Observable<CurrentApp>; | ||
constructor(args: { | ||
@@ -27,2 +27,3 @@ config: AppModuleConfig; | ||
setCurrentApp(appKeyOrApp: string | App): void; | ||
clearCurrentApp(): void; | ||
createApp(value: AppBundleStateInitial): App; | ||
@@ -29,0 +30,0 @@ dispose(): void; |
@@ -6,2 +6,3 @@ import { AnyModule, CombinedModules, ModulesInstance } from '@equinor/fusion-framework-module'; | ||
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery'; | ||
import App from './app'; | ||
type Fusion = any; | ||
@@ -16,2 +17,3 @@ export type AppEnv<TConfig = unknown, TProps = unknown> = { | ||
export type AppType = 'standalone' | 'report' | 'launcher'; | ||
export type CurrentApp = App | null | undefined; | ||
export type AppAuth = { | ||
@@ -28,3 +30,3 @@ clientId: string; | ||
export type AppManifest = { | ||
appKey: string; | ||
key: string; | ||
name: string; | ||
@@ -31,0 +33,0 @@ entry: string; |
{ | ||
"name": "@equinor/fusion-framework-module-app", | ||
"version": "2.8.1", | ||
"version": "3.1.0", | ||
"description": "", | ||
@@ -48,3 +48,3 @@ "main": "dist/esm/index.js", | ||
}, | ||
"gitHead": "67ca85013eb60fc1a01c32502c044daa1e9eff3c" | ||
"gitHead": "f59aa259d4e9f08cb1111f3efeb117ff2f023d62" | ||
} |
import { | ||
BehaviorSubject, | ||
catchError, | ||
distinctUntilKeyChanged, | ||
distinctUntilChanged, | ||
map, | ||
@@ -18,3 +18,3 @@ Observable, | ||
import type { AppConfig, AppManifest } from './types'; | ||
import type { AppConfig, AppManifest, CurrentApp } from './types'; | ||
@@ -36,3 +36,3 @@ import { App, filterEmpty } from './app/App'; | ||
#current$: BehaviorSubject<App | undefined>; | ||
#current$: BehaviorSubject<CurrentApp>; | ||
@@ -47,8 +47,15 @@ #subscription = new Subscription(); | ||
*/ | ||
get current(): App | undefined { | ||
get current(): CurrentApp { | ||
return this.#current$.value; | ||
} | ||
get current$(): Observable<App> { | ||
return this.#current$.pipe(filterEmpty(), distinctUntilKeyChanged('appKey')); | ||
get current$(): Observable<CurrentApp> { | ||
return this.#current$.pipe( | ||
distinctUntilChanged((prev, next) => { | ||
if (prev && next) { | ||
return prev.appKey === next.appKey; | ||
} | ||
return prev === next; | ||
}) | ||
); | ||
} | ||
@@ -61,3 +68,3 @@ | ||
this.#current$ = new BehaviorSubject<App | undefined>(undefined); | ||
this.#current$ = new BehaviorSubject<CurrentApp>(undefined); | ||
@@ -160,2 +167,6 @@ this.appClient = new Query(config.client.getAppManifest); | ||
public clearCurrentApp(): void { | ||
this.#current$.next(null); | ||
} | ||
/** | ||
@@ -162,0 +173,0 @@ * This should not be used, only for legacy creation backdoor |
@@ -6,2 +6,3 @@ import { AnyModule, CombinedModules, ModulesInstance } from '@equinor/fusion-framework-module'; | ||
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery'; | ||
import App from './app'; | ||
@@ -24,2 +25,4 @@ // TODO | ||
export type CurrentApp = App | null | undefined; | ||
export type AppAuth = { | ||
@@ -38,3 +41,3 @@ clientId: string; | ||
export type AppManifest = { | ||
appKey: string; | ||
key: string; | ||
name: string; | ||
@@ -41,0 +44,0 @@ entry: string; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
250077
2078