Skip to content
Jim Cowart edited this page May 10, 2014 · 5 revisions

postal.publish

description: publishes a message.

Background

There are two ways to publish messages in postal - using postal.publish or calling publish on a ChannelDefinition instance. The postal.publish method call is provided for convenience so that you don't always need a reference to a ChannelDefinition in order to publish.

postal.publish( envelope );

  • envelope - an object that contains:
    • channel - (optional) channel name (string). Uses DEFAULT_CHANNEL if no channel is provided.
    • topic - (required!) the topic string
    • data - (optional) value of any type. This is effectively the message body.

Example Usage:

var env = postal.publish({
	channel: "greeting",
	topic: "say.hello",
	data: {
		firstName: "Bugs",
		lastName: "Bunny"
	}
});