-
Notifications
You must be signed in to change notification settings - Fork 191
postal.getSubscribersFor
This method can be called 3 different ways:
returns: an array of all the current SubscriptionDefinition
objects which are subscribed to any topic on any channel.
Example Usage:
var results = postal.getSubscribersFor();
### postal.getSubscribersFor( options )
options
- an object that can contain one or more of the following properties:
-
channel
- (optional) the channel name -
topic
- (optional) a topic that will be compared to theSubscriptionDefinition
topic binding using theresolver
. -
context
- (optional) an instance used in awithContext
call which lets you retrieve anySubscriptionDefinition
instances that are using a specificcontext
for their callbacks.
In addition to the above properties on the options
argument, you can provide any other properties which you might have added to the SubscriptionDefinition
instance. For example, if you've added a foo
property to the subscription with a value of "bar", you can call postal.getSubscribersFor({ foo: "bar" });
.
returns: an array of SubscriptionDefinition
objects that match the query options.
Example Usage:
var results = postal.getSubscribersFor({
channel:"orders",
topic: "customer.addItem"
});
// OHSNAP! Making subscribers mad since 2011...
_.each( results, function(sub) {
sub.withDelay(4000);
});
### postal.getSubscribersFor( predicate )
predicate
- a function that takes a SubscriptionDefinition
as an argument and returns true
if the SubscriptionDefinition
should be included in the results, or false
if not.
returns: an array of SubscriptionDefinition
objects.
Example Usage:
// passing a predicate
var results = postal.getSubscribersFor(function (sub) {
return sub.foo === "bar";
});
// OHSNAP! Making subscribers mad since 2011...
_.each(results, function (sub) {
sub.withDelay(4000);
});