Event Subscription/Venue library for JavaScript
ISC License
Event Subscription/Venue library. Whole new approach:
linking
).The way events are treated is completely different. You can think of them as full requests, with headers and payload:
endpoint
s allow venues to check whether they are interestedUsage documentation is pending
npm install --save sydney
Creates a new Sydney venue. If only a Function
is provided, it is used
as the callback
. If only an Object
of any other kind is provided,
it is used as the endpoint
. If two arguments are provided, the first
is used as the endpoint
and the second as the callback
.
Note that
new
is completely optional. CallingSydney
as a function directly will have the same effect.
Object
endpointFunction
callbackSydney
thisAdds Sydney.prototype
methods as mixin to the vanillaSubscriber
.
If the venue has an endpoint
, it calls match
with the event
and
only calls the callback
if the return value is true
. If there is no
endpoint
it always calls the callback
. The callback is called with
the event
as the first argument and the venue (this
) as the second
argument.
If there is no callback
, the event is broadcasted to the subscribers
instead. That is done by calling broadcast
with the event
as
argument.
Object
eventSydney
thisCalls send
with the provided event
in all the subscribers.
Object
eventSydney
thisIf the subscriber
is a Sydney
venue, it just adds it as a
subscriber in the current venue.
If the subscriber
is not a Sydney
module, it adds all of Sydney
methods to the subscriber
. It doesn't override properties already
existing on the subscriber
.
Sydney
thisRemoves the subscriber
from the venue.
Object
subscriberSydney
thisIf the subscriber
is a Sydney
venue, it just adds it as a
subscriber in the current venue. Then adds the venue back into the
subscriber.
If the subscriber
is not a Sydney
module, it adds all of Sydney
methods to the subscriber
. It doesn't override properties already
existing on the subscriber
.
Sydney
thisRemoves the subscriber
from the venue and removes the venue from
the subscriber
.
Object
subscriberSydney
thisgit clone git://github.com/xaviervia/sydney
cd sydney
npm install
make test
Copyright 2015 Xavier Via
ISC license.
See LICENSE attached.