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) {
+ (fun: ObservableFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2)
+ {
return from(this.pluginService.ensurePluginsAreLoaded(scope))
.pipe(
mergeMap(() => this.wrapObject(params, hookParamName)),
)
}
- 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.wrapObject(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 }))
}
+
+ private wrapObject<T, U extends ClientFilterHookName> (result: T, hookName: U) {
+ return this.pluginService.runHook(hookName, result)
+ }
}
import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core'
+import { HooksService } from '@app/core/plugins/hooks.service'
const icons = {
'add': require('!!raw-loader?!../../../assets/images/global/add.svg'),
export class GlobalIconComponent implements OnInit {
@Input() iconName: GlobalIconName
- constructor (private el: ElementRef) {}
+ constructor (
+ private el: ElementRef,
+ private hooks: HooksService
+ ) { }
- ngOnInit () {
+ async ngOnInit () {
const nativeElement = this.el.nativeElement
- nativeElement.innerHTML = icons[this.iconName]
+ nativeElement.innerHTML = await this.hooks.wrapFun(
+ this.getSVGContent.bind(this),
+ { name: this.iconName },
+ 'common',
+ 'filter:internal.common.svg-icons.get-content.params',
+ 'filter:internal.common.svg-icons.get-content.result'
+ )
+ }
+
+ private getSVGContent (options: { name: string }) {
+ return icons[options.name]
}
}
'filter:api.signup.registration.create.params': true,
// Filter the options to create our player
- 'filter:internal.video-watch.player.build-options.result': true
+ 'filter:internal.video-watch.player.build-options.params': true,
+ 'filter:internal.video-watch.player.build-options.result': true,
+
+ // Filter our SVG icons content
+ 'filter:internal.common.svg-icons.get-content.params': true,
+ 'filter:internal.common.svg-icons.get-content.result': true
}
export type ClientFilterHookName = keyof typeof clientFilterHookObject