Skip to content

Proposal: Event API #64

@biowaffeln

Description

@biowaffeln

idea

I would like to propose an API for papers to communicate with each other by sending events.
The idea came from a usecase like in this tweet - basically a setup in which one has a keyboard-paper that emits events (e.g. keypress) and sends them to another paper, which can then handle those events.

the API

The API would look similar to that of the Node Event API. A paper could emit events like so:

/* paper.emit(eventname, paperNumber, data) */
paper.emit('keypress', '123', {key: 'a'})

with the second parameter specifying the paper to which you want to send the event. Alternatively one could also have a broadcast method if one wanted to send an event to all papers:

paper.broadcast('keypress', {key: 'a'})

and handling of events would look like so:

paper.on('keypress', function(data) {
  // do something
})  

Any opinions on that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions