PublishSubscribe, v1.0.0

A cross document message service that allows JavaScript to send and receive messages between web pages within one or more browsers (cross document + cross process).

NOTE: PublishSubscribe depends on RubyInterpreter.

BrowserPlus.PublishSubscribe.addListener({params}, function{}())

Subscribe to the pubsub mechanism.

Test: addListener()

Parameters

receiver: callback
JavaScript function that is notified of a message. The value passed to the callback contains {data:(Any), origin:(String)}
origin: string (Optional)
Optional string that specifies the domain ("http://example.com") to accept messages from. Defaults to all ("*"). This is not part of the HTML5 spec but allows automatic filtering of events so JavaScript listener does not have to manually check event.origin.

BrowserPlus.PublishSubscribe.postMessage({params}, function{}())

Post a message. The message posted is associated with the domain of the sender. Receivers may elect to filter messages based on the domain.

Test: postMessage()

Parameters

data: any
The data object (Object, Array, String, Boolean, Integer, Float, Boolean, Null) that is posted to all interested subscribers. All other data types are stripped out of the passed object.
targetOrigin: string
The origin specifies where to send the message to. Options are either an URI like "http://example.org" or "*" to pass it to all listeners.