(func: (newValue: T) => void, options: Options = {})
| 15 | } |
| 16 | |
| 17 | public subscribe(func: (newValue: T) => void, options: Options = {}) { |
| 18 | // Setup the defaults if they weren't specified |
| 19 | if (options.times === undefined) { |
| 20 | options.times = Infinity; |
| 21 | } |
| 22 | if (options.callOnSubscribe === undefined) { |
| 23 | options.callOnSubscribe = true; |
| 24 | } |
| 25 | |
| 26 | if (options.callOnSubscribe) { |
| 27 | func(this.t); |
| 28 | } |
| 29 | if (options.times > 0) { |
| 30 | this.subscriptions.push({ func: func, times: options.times }); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | public unsubscribe(func: (newValue: T) => void) { |
| 35 | for (let i = 0; i < this.subscriptions.length; i++) { |
no test coverage detected