Skip to main content

Bridge.Context

The context holds information specific to an appointment. The initial state is set on appointment creation, and can be fetched and added to by the content during a presentation.

.get(key, [defaultValue])​

Return the context variable belonging to key.

let state = Bridge.Context.get("toggle-button-state", false);

.set(key, value)​

Set the context variable key to have the argued value.

Bridge.Context.set("toggle-button-state", true);

.setPath(path, value)​

Set the value provided to the path destination, creating object or array containers along the way if they do not already exist.

Bridge.Context.setPath(".tables .newtable .rows .0 .visible", false);

Updated context:

{
"tables": {
"newtable": {
"rows": [
{
"visible": false
}
]
}
}
}

.on(event, listener) / .off(event, listener)​

Listens for "changed", which fires whenever any part of the context is set.

function onChanged() {
// Fires for the whole context, so read back the key you care about.
const region = Bridge.Context.get("customer.region");
}

Bridge.Context.on("changed", onChanged);
Bridge.Context.off("changed", onChanged);

The event doesn't say which key changed, unlike Bridge.CMSVals, so a slide watching one value reads it back and compares. Call .off(...) when the slide closes, or the listener keeps running after it.

.getDict()​

Gets the context data as an object, can be useful for debugging.

Example response:

{
"attendees": [
{
"email": "john.smith@companyco.com",
"full_name": "John Smith",
"first_name": "John",
"last_name": "Smith",
"notes": ""
}
],
"customers": [
{
"name": "Company Co.",
"logo": "http://www.companyco.com/logo.png",
"primary_color": "#abc123",
"notes": ""
}
],
"user": {
"email": "user@partner.com",
"first_name": "Jane",
"last_name": "Doe",
"phone": "0400 000 000"
}
}

.save()​

Used to immediately save the current context changes to the server.

Returns:

Returns a Promise containing an object with a snapshot URL.

const resp = await Bridge.Context.save();

console.log(resp.snapshot); // http://path/to/server/api/snapshots/1/
In general you shouldn't need to do this - saving context is an automatic process that happens when you

change slide, close the presentation, etc. This is done in this wait to prevent overloading the server. Only use this function if you have a good reason. :::

.match(selector, defaultValue)​

Use a css-style selector to look into the context. If you use match as opposed to match_many, then you are indicating that you expect to get a single match result.

See jsonselect for the documentation on how these selectors work.

const customerName = Bridge.Context.match(".customer .name", "John Smith");

.match_many(selector, defaultValue)​

Use a css-style selector to look into the context. If you use match_many as opposed to match, then you are indicating that you expect to get one or more matches.

const products = Bridge.Context.match_many(".products", []);

.getAgenda()​

Returns a nested set of decks suitable for producing an agenda slide.

Example response:

Returns an array of decks assigned to the presentation.

[{
"enabled": false,
"path": "awesome",
"sections": [{
"path": "awesome/were_innovative",
"title": "We're innovative",
"visible": true,
"slides": [{
"path": "awesome/were_innovative/introduction",
"title": "Introduction",
"visible": true,
"subslides:" []
}, {
"path": "awesome/were_innovative/super_stats",
"title": "Super stats",
"visible": true,
"subslides:" []
}, {
"path": "awesome/were_innovative/fancy_infographic",
"title": "Fancy infographic",
"visible": true,
"subslides:" [{
"title": ""
"visible": true
}, {
"title": ""
"visible": true
}]
}, {
"..."
}]
}, {
"..."
}],
"title": "Digital is awesome"
}]
LivePreso's current configuration only allows one deck assigned per presentation. This is planned to be expanded

on in the future. :::