Skip to content

Notifications: More Generic events #151

Closed
@ya7ya

Description

@ya7ya

Hey @diasdavid and the IPFS team, I'm building something that requires getting a notification from bitswap._notification and noticed that it doesn't have more generic events, events are triggered with a string that includes the block.cid usually. so creating a listener that listens to all block:* isn't that straightforward.

What if instead of using something like eventemitter2 that adds wildcard and other functionalities , we can just trigger a more generic event like so

// current implementation (notification.js)
hasBlock (block) {
    const str = `block:${block.cid.buffer.toString()}`
    this._log(str)
    this.emit(str, block)
 }

// proposed change
hasBlock (block) {
    const str = `block:${block.cid.buffer.toString()}`
    this._log(str)
    this.emit(str, block)
    // generic event
    this.emit('block', block)
}

What do you think?? Is this something you'd be interested in adding or not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low: Not priority right nowkind/supportA question or request for supportstatus/readyReady to be worked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions