Shared modules in web extensions

Adobe Experience Platform Launch has been rebranded as a suite of data collection technologies in Adobe Experience Platform. Several terminology changes have rolled out across the product documentation as a result. 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. For example, Extension A may load a piece of data asynchronously and make it available to Extension B via a promise.

In JavaScript implementations, all shared modules are instantiated using the getSharedModule method provided by the turbine free variable.

Shared modules are included in tag libraries even when they are never called from inside other extensions. In order to not increase the library size unnecessarily, you should be careful about what you expose as a shared module.

Shared modules do not have a view component.

When developing your own tag 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).