All files / services/plugin plugin.service.ts

57.14% Statements 8/14
100% Branches 0/0
14.29% Functions 1/7
50% Lines 6/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 361x   1x     1x   1x 1x 1x                                                    
import { BehaviorSubject } from 'rxjs';
// import { PluginBase, PluginNameVersion, PluginPackage } from 'hapi';
import { Service, PluginInterface } from '../../container';
 
@Service()
export class PluginService {
 
    private plugins: BehaviorSubject<Array<PluginInterface>> = new BehaviorSubject([]);
    private beforePlugins: BehaviorSubject<Array<Function | PluginInterface>> = new BehaviorSubject([]);
    private afterPlugins: BehaviorSubject<Array<Function | PluginInterface>> = new BehaviorSubject([]);
 
    register(plugin) {
        this.plugins.next([...this.plugins.getValue(), plugin]);
    }
 
    registerBefore(plugin) {
        this.beforePlugins.next([...this.plugins.getValue(), plugin]);
    }
 
    registerAfter(plugin) {
        this.afterPlugins.next([...this.plugins.getValue(), plugin]);
    }
 
    getPlugins(): Array<Function | PluginInterface> {
        return this.plugins.getValue();
    }
 
    getAfterPlugins() {
        return this.afterPlugins.getValue();
    }
 
    getBeforePlugins() {
        return this.beforePlugins.getValue();
    }
 
}