mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
fix listen once
This commit is contained in:
parent
0c3c21b4c5
commit
17f1b3e53e
@ -26,10 +26,12 @@ export default class Event {
|
||||
this.interval)
|
||||
}
|
||||
|
||||
public async listenOnce() {
|
||||
public listenOnce(callback: any) {
|
||||
this.listen((events: any[]) => {
|
||||
EventListener.unsubscribe(this)
|
||||
return events
|
||||
if (events) {
|
||||
EventListener.unsubscribe(this)
|
||||
callback(events[0])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ export default class Ocean {
|
||||
|
||||
const storedDdo = await aquarius.storeDDO(ddo)
|
||||
|
||||
Logger.log(JSON.stringify(storedDdo, null, 2))
|
||||
// Logger.log(JSON.stringify(storedDdo, null, 2))
|
||||
|
||||
await didRegistry.registerAttribute(
|
||||
assetId,
|
||||
|
@ -52,19 +52,25 @@ describe("EventListener", () => {
|
||||
|
||||
describe("#listenOnce()", () => {
|
||||
|
||||
xit("should listen once", async () => {
|
||||
it("should listen once", (done) => {
|
||||
|
||||
const acc = accounts[1]
|
||||
|
||||
const countBefore = EventListener.count()
|
||||
const event = EventListener.subscribe("OceanToken",
|
||||
"Transfer",
|
||||
{
|
||||
to: acc.getId(),
|
||||
})
|
||||
|
||||
const events = await event.listenOnce()
|
||||
event.listenOnce(
|
||||
(data: any) => {
|
||||
|
||||
assert(events, "no events")
|
||||
assert(data)
|
||||
assert(data.blockNumber)
|
||||
assert(EventListener.count() === countBefore)
|
||||
done()
|
||||
})
|
||||
|
||||
const {market} = keeper
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user