All files / @angular Store.ts

25% Statements 2/8
0% Branches 0/2
33.33% Functions 1/3
33.33% Lines 2/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20                          1x           1x
import { STATEX_ACTION_KEY } from '../core/constance'
 
/**
 * Use reflection library
 */
declare var Reflect: any
 
/**
 * Extend this class to create a store
 *
 * @export
 * @class Store
 */
export class Store {
  constructor() {
    if (!Reflect.hasMetadata(STATEX_ACTION_KEY, this)) return
    let statexActions = Reflect.getMetadata(STATEX_ACTION_KEY, this)
    Object.keys(statexActions).forEach(name => new statexActions[name]().subscribe(this[name], this))
  }
}