For Developers

Reference

createWidget()

Creates a new widget instance.

const widget = edlink.createWidget();

createOnboarding()

Creates a new onboarding instance.

const onboarding = edlink.createOnboarding();

Widget Instance Methods

activatePlugin(config)

Activates a plugin on the widget instance. Widgets can only ever activate one plugin. To mount a new plugin call createWidget and create a new instance.

widget.activatePlugin({
    name: 'authentication',
    options: {
        redirect_uri: 'https://acme.com/auth/callback'
    }
});

show()

Reveals the widget if hidden. Widgets are hidden by default on creation.

widget.show();

hide()

Hides the widget. Stay in the DOM but hidden.

widget.hide();

destroy()

Destroys the widget instance. Unmounts from the DOM.

widget.destroy();

on(event, handler)

Attaches an event listener to the widget instance. Each plugin has its own set of events that can be listened to. See the plugin documentation for specific events.

widget.on('event', (data) => {
    console.log(data);
});

off(event, handler)

Removes an event listener from the widget instance.

widget.off('event', handler);

Events

Each plugin has its own set of events that can be listened to. See the plugin documentation for specific events.

However there are some events that are global to all widgets. These are:

  • close - Emitted when some action in the widget causes it to close. Results in the widget being hidden.
  • destroy - Emitted when the widget is destroyed. Results in the widget being unmounted from the DOM.