@equinor/fusion-framework-module
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.4.1](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-module@0.4.0...@equinor/fusion-framework-module@0.4.1) (2022-08-15) | ||
### Bug Fixes | ||
* enhance post initialize ([4d10184](https://github.com/equinor/fusion-framework/commit/4d10184bf89d8968360be726ec3885444999ef8f)) | ||
# 0.4.0 (2022-08-11) | ||
@@ -8,0 +19,0 @@ |
@@ -89,13 +89,18 @@ import { BehaviorSubject, filter, firstValueFrom, from, lastValueFrom, map, mergeMap, scan, throwError, timeout, } from 'rxjs'; | ||
Object.seal(instance); | ||
const postInitialize = [...modules.map((x) => x.postInitialize), ...afterInit]; | ||
await Promise.all(postInitialize.map((x) => Promise.resolve(x?.(instance)))); | ||
await Promise.allSettled(modules.map(async (x) => { | ||
await x.postInitialize?.({ | ||
ref, | ||
modules: instance, | ||
instance: instance[x.name], | ||
}); | ||
})); | ||
logger.debug('✅ post initialized'); | ||
logger.info(`🚀 ${!ref ? 'modules' : 'sub-modules'} ready`, process.env.NODE_ENV === 'development' && instance); | ||
const dispose = async () => { | ||
await Promise.allSettled(modules.map((module) => { | ||
Promise.resolve(module.dispose?.({ | ||
await Promise.allSettled(modules.map(async (module) => { | ||
await module.dispose?.({ | ||
ref, | ||
modules: instance, | ||
instance: modules[module.name], | ||
})); | ||
}); | ||
})); | ||
@@ -102,0 +107,0 @@ }; |
@@ -10,3 +10,7 @@ export interface Module<TKey extends string, TType, TConfig, TDeps extends Array<AnyModule> = []> { | ||
}) => TType | Promise<TType>; | ||
postInitialize?: (modules: Record<TKey, TType> & ModulesInstanceType<ModulesType<TDeps>>) => void | Promise<void>; | ||
postInitialize?: (args: { | ||
ref?: any; | ||
instance: TType; | ||
modules: Record<TKey, TType> & ModulesInstanceType<ModulesType<TDeps>>; | ||
}) => void | Promise<void>; | ||
dispose?: (args: { | ||
@@ -13,0 +17,0 @@ ref?: any; |
{ | ||
"name": "@equinor/fusion-framework-module", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "", | ||
@@ -31,3 +31,3 @@ "main": "dist/esm/index.js", | ||
}, | ||
"gitHead": "b578e1812564df3aac4313c1b38e7252e7c9dd83" | ||
"gitHead": "293ea245afed24ebcbbf04cb4be66210d7705af9" | ||
} |
@@ -183,4 +183,11 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/** call all added post config hooks */ | ||
const postInitialize = [...modules.map((x) => x.postInitialize), ...afterInit]; | ||
await Promise.all(postInitialize.map((x) => Promise.resolve(x?.(instance)))); | ||
await Promise.allSettled( | ||
modules.map(async (x) => { | ||
await x.postInitialize?.({ | ||
ref, | ||
modules: instance, | ||
instance: instance[x.name], | ||
}); | ||
}) | ||
); | ||
logger.debug('✅ post initialized'); | ||
@@ -195,10 +202,8 @@ | ||
await Promise.allSettled( | ||
modules.map((module) => { | ||
Promise.resolve( | ||
module.dispose?.({ | ||
ref, | ||
modules: instance, | ||
instance: modules[module.name], | ||
}) | ||
); | ||
modules.map(async (module) => { | ||
await module.dispose?.({ | ||
ref, | ||
modules: instance, | ||
instance: modules[module.name], | ||
}); | ||
}) | ||
@@ -205,0 +210,0 @@ ); |
@@ -17,5 +17,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
}) => TType | Promise<TType>; | ||
postInitialize?: ( | ||
modules: Record<TKey, TType> & ModulesInstanceType<ModulesType<TDeps>> | ||
) => void | Promise<void>; | ||
postInitialize?: (args: { | ||
ref?: any; | ||
instance: TType; | ||
modules: Record<TKey, TType> & ModulesInstanceType<ModulesType<TDeps>>; | ||
}) => void | Promise<void>; | ||
dispose?: (args: { | ||
@@ -22,0 +24,0 @@ ref?: any; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89938
446