123456789101112131415161718192021222324252627282930313233343536 |
- 'use strict';
- Object.defineProperty(exports, '__esModule', { value: true });
- class Subscribable {
- constructor() {
- this.listeners = new Set();
- this.subscribe = this.subscribe.bind(this);
- }
- subscribe(listener) {
- const identity = {
- listener
- };
- this.listeners.add(identity);
- this.onSubscribe();
- return () => {
- this.listeners.delete(identity);
- this.onUnsubscribe();
- };
- }
- hasListeners() {
- return this.listeners.size > 0;
- }
- onSubscribe() {// Do nothing
- }
- onUnsubscribe() {// Do nothing
- }
- }
- exports.Subscribable = Subscribable;
- //# sourceMappingURL=subscribable.js.map
|