Namespace: clbApp

Member Of Module: clb-app

Description

An AngularJS service to interface a web application with the HBP Collaboratory. This library provides a few helper to work within the Collaboratory environment.

Usage

  • Function: context is used to set and retrieve the current context.
  • Function: emit is used to send a command to the HBP Collaboratory and wait for its answer.

Function: emit

Send a message to the HBP Collaboratory.

emit(name, data)
Arguments:
  • name (string) – name of the event to be propagated
  • data (object) – corresponding data to be sent alongside the event
Return Promise:

resolve with the message response

Function: context

Asynchronously retrieve the current HBP Collaboratory Context, including the mode, the ctx UUID and the application state if any.

context(data)
Arguments:
  • data (object) – new values to send to HBP Collaboratory frontend
Return Promise:

resolve to the context

Function: open

Open a resource described by the given ObjectReference.

The promise will fulfill only if the navigation is possible. Otherwise, an error will be returned.

open(ref)
Arguments:
  • ref (ObjectReference) – The object reference to navigate to
Return Promise:

The promise retrieved by the call to emit

Typedef: HbpCollaboratoryContext

Properties

  • string mode: the current mode, either ‘run’ or ‘edit’
  • string ctx: the UUID of the current context
  • string state: an application defined state string

Examples

Retrieve the current context object
clbApp.context()
.then(function(context) {
  console.log(context.ctx, context.state, context.collab);
})
.catch(function(err) {
  // Cannot set the state
});
Set the current state in order for a user to be able to copy-paste its current URL and reopen the same collab with your app loaded at the same place.
clbApp.context({state: 'lorem ipsum'})
.then(function(context) {
  console.log(context.ctx, context.state, context.collab);
})
.catch(function(err) {
  // Cannot set the state
});