Shared modules in web extensions

Note: Adobe Experience Platform Launch is being rebranded as a suite of data collection technologies in Experience Platform. These changes will be rolling out across all product documentation in the coming weeks. Please refer to the following document for a consolidated reference of the terminology changes.

A shared module is a mechanism by which you can communicate with other extensions. In JavaScript implementations, all shared modules are instantiated using the getSharedModule method provided by the turbine free variable.

When developing your own Platform Launch extension, you can define any shared modules you want it to provide. For example, you can create a module that loads a user ID asynchronously and then shares the user ID with any other extension via a promise:

var userIdPromise = new Promise(/* load user id, then resolve promise */);
module.exports = userIdPromise;

In the extension manifest you have to provide a name for this shared module. If you name it user-id-promise, a different extension could then access this shared module as follows:

var userIdPromise = turbine.getSharedModule('user-extension', 'user-id-promise');

Shared modules can be anything you would typically be able to export from a CommonJS module (such as functions, objects, strings, numbers, or booleans).

On this page