1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/src/keeper/EventListener.ts

30 lines
704 B
TypeScript
Raw Normal View History

2018-11-23 11:39:16 +01:00
import Event from "./Event"
export default class EventListener {
2018-11-23 11:47:39 +01:00
public static subscribe(contractName: string,
eventName: string,
filter: any): Event {
2018-11-23 11:39:16 +01:00
const event = new Event(contractName, eventName, filter)
EventListener.events.push(event)
return event
}
2018-11-23 11:47:39 +01:00
public static unsubscribe(event): boolean {
event.stopListen()
const i = EventListener.events.indexOf(event)
if (i > -1) {
EventListener.events.splice(i, 1)
}
2018-11-23 11:39:16 +01:00
return true
}
2018-11-23 11:47:39 +01:00
public static count() {
return EventListener.events.length
}
2018-11-23 11:47:39 +01:00
private static events: Event[] = []
2018-11-23 11:39:16 +01:00
}