Documentation ¶
Overview ¶
Package iframes provides abstractions for inter-iframe communication
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterListener ¶
func RegisterListener(mtype string, lf ListenerFunc)
RegisterListener registers a ListnerFunc to receive messages of the given type.
func UnregisterIframe ¶
UnregisterIframe unregisters the iframe. This should be called whenever the iframe is removed from the DOM. Any Respond functions corresponding to this iframe will be invalidated.
Types ¶
type ListenerFunc ¶
ListenerFunc is a function which responds to a parsed iframe message. It receives the original payload, and a function which may be called with a response to the original iframe.
A ListenerFunc is called as a JS callback, so it may not block.
type Message ¶
type Message struct { *js.Object Type string `js:"type"` IframeID string `js:"iframeID"` CardID string `js:"cardID"` Payload *js.Object `js:"payload"` }
Message is a message to be sent to or received from an iframe
type Respond ¶
Respond sends a response to the iframe
func RegisterIframe ¶
RegisterIframe associates an iframe ID with a card ID so that requests can be served. A Responder is returned, which may then be used to send messages to the iframe.