private pluginService: PluginService
) { }
- wrapObject<T, U extends ClientFilterHookName> (result: T, hookName: U) {
- return this.pluginService.runHook(hookName, result)
- }
-
wrapObsFun
<P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName>
(fun: ObservableFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) {
return from(this.pluginService.ensurePluginsAreLoaded(scope))
.pipe(
- mergeMap(() => this.wrapObject(params, hookParamName)),
+ mergeMap(() => this.wrapObjectWithoutScopeLoad(params, hookParamName)),
switchMap(params => fun(params)),
mergeMap(result => this.pluginService.runHook(hookResultName, result, params))
)
}
- async wrapFun<U, T, V extends ClientFilterHookName> (fun: RawFunction<U, T>, params: U, hookName: V) {
- const result = fun(params)
+ async wrapFun
+ <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName>
+ (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) {
+ await this.pluginService.ensurePluginsAreLoaded(scope)
+
+ const newParams = await this.wrapObjectWithoutScopeLoad(params, hookParamName)
+ const result = fun(newParams)
- return this.pluginService.runHook(hookName, result, params)
+ return this.pluginService.runHook(hookResultName, result, params)
}
runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) {
.then(() => this.pluginService.runHook(hookName, undefined, params))
.catch((err: any) => console.error('Fatal hook error.', { err }))
}
+
+ async wrapObject<T, U extends ClientFilterHookName> (result: T, scope: PluginClientScope, hookName: U) {
+ await this.pluginService.ensurePluginsAreLoaded(scope)
+
+ return this.wrapObjectWithoutScopeLoad(result, hookName)
+ }
+
+ private wrapObjectWithoutScopeLoad<T, U extends ClientFilterHookName> (result: T, hookName: U) {
+ return this.pluginService.runHook(hookName, result)
+ }
}