D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
forge
/
ebrokers.online
/
node_modules
/
@tanstack
/
query-core
/
src
/
Filename :
subscribable.ts
back
Copy
export class Subscribable<TListener extends Function> { protected listeners = new Set<TListener>() constructor() { this.subscribe = this.subscribe.bind(this) } subscribe(listener: TListener): () => void { this.listeners.add(listener) this.onSubscribe() return () => { this.listeners.delete(listener) this.onUnsubscribe() } } hasListeners(): boolean { return this.listeners.size > 0 } protected onSubscribe(): void { // Do nothing } protected onUnsubscribe(): void { // Do nothing } }