mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
make event listener static
This commit is contained in:
parent
df475b6958
commit
f37a1cc1c6
@ -2,9 +2,7 @@ import Event from "./Event"
|
||||
|
||||
export default class EventListener {
|
||||
|
||||
private static events: Event[] = []
|
||||
|
||||
public subscribe(contractName: string,
|
||||
public static subscribe(contractName: string,
|
||||
eventName: string,
|
||||
filter: any): Event {
|
||||
|
||||
@ -14,7 +12,7 @@ export default class EventListener {
|
||||
return event
|
||||
}
|
||||
|
||||
public unsubscribe(event): boolean {
|
||||
public static unsubscribe(event): boolean {
|
||||
|
||||
EventListener.events = EventListener.events.splice(
|
||||
EventListener.events.findIndex((e) => e === event),
|
||||
@ -22,4 +20,6 @@ export default class EventListener {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private static events: Event[] = []
|
||||
}
|
||||
|
@ -28,10 +28,9 @@ describe("EventListener", () => {
|
||||
|
||||
it("should subscribe to an event", (done) => {
|
||||
|
||||
const eventListener = new EventListener()
|
||||
const acc = accounts[1]
|
||||
|
||||
const event = eventListener.subscribe("OceanToken",
|
||||
const event = EventListener.subscribe("OceanToken",
|
||||
"Transfer",
|
||||
{
|
||||
to: acc.getId(),
|
||||
@ -55,13 +54,11 @@ describe("EventListener", () => {
|
||||
|
||||
it("should subscribe to an event", (done) => {
|
||||
|
||||
const eventListener = new EventListener()
|
||||
|
||||
const event = eventListener.subscribe("OceanToken",
|
||||
const event = EventListener.subscribe("OceanToken",
|
||||
"Transfer",
|
||||
{})
|
||||
|
||||
const unsubscribed = eventListener.unsubscribe(event)
|
||||
const unsubscribed = EventListener.unsubscribe(event)
|
||||
assert(unsubscribed)
|
||||
|
||||
done()
|
||||
|
Loading…
Reference in New Issue
Block a user