Mediator.js icon indicating copy to clipboard operation
Mediator.js copied to clipboard

Support chaining

Open jacobtoye opened this issue 11 years ago • 3 comments

Have you through of adding chaining to subscribe, once and remove methods?

E.g.

Mediator
     .subscribe('channe:one', doOne)
     .subscribe('channel:two', doTwo)
     .subscribe('channe:three', doThree)

I notice subscribe and once return the subscriber. What is the use case for this?

If this would be a positive change I'd be happy to submit a pull.

jacobtoye avatar Apr 08 '13 02:04 jacobtoye

I'm currently returning the subscriber so that you can later do things like update priority or options for that specific subscriber without needing a reference to the function (since subscriber returns a guid for reference.)

What do you think about providing a chain() method, like

Mediator.chain()
    .subscribe('channel:one', doOne)
    .subscribe('channel:two', doTwo)

ajacksified avatar Apr 08 '13 18:04 ajacksified

Yeah a chain() would be fine. Good idea.

jacobtoye avatar Apr 08 '13 21:04 jacobtoye

So, when will you add chaining? :)

Anachron avatar Feb 20 '14 12:02 Anachron