Skip to content

postal.unsubscribeFor

ifandelse edited this page May 10, 2014 · 1 revision

postal.unsubscribeFor

Unsubscribes any SubscriptionDefinition instances matching the provided arguments

This method can be called 3 different ways:


postal.unsubscribeFor()

Unsubscribes all of the current SubscriptionDefinition objects which are subscribed to any topic on any channel.

Example Usage:

postal.unsubscribeFor();

### postal.unsubscribeFor( options )

Unsubscribes any SubscriptionDefinition matching the options data provided.

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 the SubscriptionDefinition topic binding using the resolver.
  • context - (optional) an instance used in a withContext call which lets you unsubscribe any SubscriptionDefinition instances that are using a specific context 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.unsubscribeFor({ foo: "bar" });.

Example Usage:

var results = postal.unsubscribeFor({
  channel:"orders",
  topic: "customer.addItem"
});

### postal.utils.getSubscribersFor( predicate )

Unsubscribes any SubscriptionDefinition matching the predicate data provided.

predicate - a function that takes a SubscriptionDefinition as an argument and returns true if the SubscriptionDefinition should be unsubscribed, or false if not.

Example Usage:

// passing a predicate
var results = postal.getSubscribersFor(function (sub) {
    return sub.foo === "bar";
});