Shared modules in web extensions

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(/*%20load%20user%20id,%20then%20resolve%20promise%20*/?lang=en);
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