Zotonic Cotonic models Cotonic

These browser-side models extend Cotonic with Zotonic functionality. Each model has its own reference page:

ModelPurpose
model/authAuthentication state and operations.
model/auth-uiLogin and account recovery interfaces.
model/oauthOAuth authorization and redirect flows.
model/fileuploaderChunked uploads and upload queues.
model/loadmoreReplace a loader with server-rendered content.
model/alertAlert dialogs.
model/clipboardCopy text to the clipboard.
model/wiresTrigger named Zotonic events.
model/consoleBrowser console logging and ping replies.
model/activityBrowser activity events; no request topics.

Calling conventions

Use cotonic.broker.publish(topic, payload) for commands and cotonic.broker.subscribe(topic, callback) for events. The callback receives a message whose payload contains the data. Within a worker, use self.publish and self.subscribe.

Use cotonic.broker.call or self.call only where the operation documents a response. Many commands publish events or update the interface without replying to the request's response topic.

Client topics start with model/. A topic such as bridge/origin/model/fileuploader/post/new addresses a server-side Zotonic model; it is a different API from model/fileuploader/post/new in the browser.

Availability depends on the scripts and workers loaded by the page. Cotonic's own models, including cotonic#sessionId, cotonic#ui, and cotonic#location, are documented in the Cotonic reference maintained in its repository.

Edit on GitHub