Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
javascript
javascript
gadgets.ee.registerContextListener(function(context) {
  //Do something with the context
});

Additional Considerations:

We also need to support the ability for a gadget to get the parent object containing the embedded experience.  There should be a similar API to accomplish that as well, but those discussions are on going at the moment.  See this wiki page.

<static> gadgets.ee.registerRootContextListener(listener)

Description: Registers a listener for when the root object containing this embedded experience is passed to the object.  The embedded experience data model is contained within the root object being passed.

Parameters:

Name

Type

Description

listener

Function

A function that will be called when the root object containing this embedded experience is passed to the gadget.  The function should take one parameter which is a JSON object representing a root context object.

Example:

...


gadgets.ee.registerRootContextListener(function(rootContext) {
  var eeDataModel;
  if(rootContext.type === opensocial.type.ActivityEntry) {
    eeDataModel = rootContext.root.openSocial.embed;
  } else if(rootContext.type === opensocial.type.Message) {  
    //At the time this proposal was written EE was not integrated into the OpenSocial Message object
    eeDataModel = rootContext.root.embed;
  } else if(rootContext.type === opensocial.type.SearchResult) {  
    //At the time this proposal was written there is no SearchResult object in the OpenSocial spec
    eeDataModel = rootContext.root.embed;
  } else {
    gadgets.error('Unknown type');
  }
});

<static> gadgets.ee.getEmbeddedExperiencesDataModel(rootContext)

Description: Given an embedded experiences root context object it will return the embedded experiences data model.

Returns: An embedded experiences data model.

Parameters:

Name

Type

Description

rootContext

opensocial.ee.RootContext

The embedded experiences root context object, ie an activity entry, message, etc, to get the embedded experiences data model from.

Example:

...


gadgets.ee.getEmbeddedExperiencesDataModel(function(rootContext) {
  var eeDataModel = getEmbeddedExperiencesDataModel(rootContext);
  if(!eeDataModel) {
    gadgets.error('No data model');
    return;
  }
  //Do something with the data model
});

Embedded Experiences Root Context Object

The embedded experience root context object is an object that represents the type of OpenSocial data object containing the embedded experience.  The possible data types include

  • An Activity Stream activity.
  • A Message - We need to define this.
  • A Search Object - We need to define this.

The embedded experiences root context object has two fields.

Name

Type

Description

type

opensocial.type

Indicates the type of OpenSocial object containing the embedded experience.

root

Object

A JSON object containing the embedded experience.

opensocial.type

This is basically a set of constants defining the different OpenSocial data types.

<static> opensocial.type.ActivityEntry

Description: A constant for an activity entry in an activity stream.

<static> opensocial.type.Message

Description: A constant for the OpenSocial Message type.

Note: Proposal to introduce embedded experiences in the OpenSocial Message object is here.

<static> opensocial.type.SearchResult

Description: A constant for a search result.

Note:  We need to define Search and Search results in the OpenSocial spec.