Provides typescript decorators for classes that make methods/properties subscribable.
npm install subscribable-decoratornpm install subscribable-decorator --save`
Example
See the example/Example.ts for a working example. `npm run example`
`
import {Subscribable, Subscribe} from 'subscribable-decorator';
class ExampleClass {
constructor() {
this.bool = false;
}
@Subscribable
public bool: boolean;
@Subscribable
public setBoolTrue(myArg: string, anotherArg: string): string {
this.bool = true;
return 'The returned value';
}
}
var example = new ExampleClass();
Subscribe(example, 'bool', (...args) => {
console.log(args);
});
Subscribe(example, 'setBoolTrue', (...args) => {
console.log(args);
});
example.setBoolTrue('Argument1', 'Argument2');
// Outputs: [ true ], [ 'The returned value', [ 'Argument1', 'Argument2' ] ]
example.bool = false;
// Outputs: [ false ]
``