all files / src/ decorators.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                        
import {asyncEventDispatcher} from './async-event-dispatcher';
 
/**
 * Decorator is used to mark a method as an event listener
 *
 * @param {string} eventName
 * @param {number} priority
 * @returns {MethodDecorator}
 * @constructor
 */
export function Observe<T>(eventName: string, priority = 0): MethodDecorator {
  return function (target: Object, propertyKey: string): void {
    asyncEventDispatcher.addListener(eventName, target[propertyKey].bind(target), priority);
  };
}