Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 4 Next »

Issue 1249

Today gadget developers need to write the same few lines of javascript to access the embedded experiences context.

gadgets.util.registerOnLoadHandler(function() {
  opensocial.data.getDataContext().registerListener('org.opensocial.ee.context', function(key) {
    var context = opensocial.data.getDataContext().getDataSet(key);
    //finally do something with the context
  });
});

This code is the same for ALL embedded experience gadgets who want to access their context, no matter what.  It can be simplified and made easier for the gadget developer by wrapping all of this code in a simple API...

<static> gadgets.ee.registerContextListener(listener)

Description: Registers a listener for when the embedded experience context object is passed to the gadget. The listener will be called whenever the context object is updated for this gadget.

Parameters:

Name

Type

Description

listener

Function

A function that will be called whenever the embedded experience context is set for this gadget.  The function should take one parameter which is a JSON object representing the embedded experience context from the gadget.

Example:

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.

  • No labels