0.3.0 • Published 8 years ago

broway v0.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

broway

PubSub with the history. Broway is just a cool name.

Intro

We want to have a way to make modules communicate without thinking which one has been loaded before.

A Reader can reach all the messages that has been sent to the mailbox before it was created:

M2.mailbox('myMailBox').send(1);
M2.mailbox('myMailBox').send('another message');
// ...
M2.mailbox('myMailBox').read(console.log.bind(console)) // 1 ... 'another message'
M2.mailbox('myMailBox').send(1);
M2.mailbox('myMailBox').send('another message');
// ...
M2.mailbox('myMailBox').read(console.log.bind(console)) // 1 ... 'another message'

M2.mailbox('myMailBox').send(2);
// logs "2" from the first reader

// Create another reader
M2.mailbox('myMailBox').read(console.log.bind(console)) // 1, 'another message', 2

M2.mailbox('myMailBox').send(3);
// Logs "3" two times as we now have two readers 

Roadmap

  • add a subscribe function that will register the reader but only for the new messages. Old school pubsub.
  • mailbox will become a Functor.