Pubsub Component ReadMe Previous Releases (Managed Package)

For the managed package runtime, this page contains the Pubsub Component ReadMe for older releases.

Managed Package app icon This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.

For the most recent version of the Pubsub Component ReadMe, see Pubsub Component (Managed Package).

Vlocity Insurance and Health Spring '20

The Pubsub Component enables data sharing between components. Multiple components can register and receive data from the same channel.

This component exposes 4 functions:

  • register

  • unregister

  • fire

  • shouldExecuteCallbackHandler.shouldExecuteCallback

Available Methods

Register

Register a callback for an event.

pubsub.register(this.channel, {
        result: // Pass the payload here
    });

Unregister

Unregister from an event.

pubsub.unregister(this.channel, {
        onresult: // Do on successfull disconnect
    });

Fire

Fire an event to a listener.

pubsub.fire("Event Name ", "Name of the Action", {
        name: // some name,
        value: // payload
    });

shouldExecuteCallbackHandler.shouldExecuteCallback

Override this function to implement a check before executing the registered callback. This function should return true if you want the callback to execute or return false. The default value returned is true.

pubsub.shouldExecuteCallbackHandler.shouldExecuteCallback = (callback,payload)=>{
        //implement the function to return true if you want the callback to execute else return false.
        if(condition){ //some condition.
            return true;
        }else{
            return false;
        }
    }

Register and Receive Data from Multiple Components

// Inside sending component
    pubsub.fire("Notify", "sendNotification", {
        name: "Notify",
        value: // payload
    });

    // Inside receving component 1
    pubsub.register("Notify", {
        sendNotification: //Do something
    });

    // Inside receving component 2
    pubsub.register("Notify", {
        sendNotification: //Do something else
    });

Vlocity Insurance and Health Summer '19 and CME Fall '19

The Pubsub Component enables data sharing between components. Multiple components can register and receive data from the same channel.

This component exposes 3 functions:

  • register

  • unregister

  • fire

Available Methods

Register

Register a callback for an event.

pubsub.register(this.channel, {
        result: // Pass the payload here
    });

Unregister

Unregister from an event.

pubsub.unregister(this.channel, {
        onresult: // Do on successfull disconnect
    });

Fire

Fire an event to a listener.

pubsub.fire("Event Name ", "Name of the Action", {
        name: // some name,
        value: // payload
    });

Register and Receive Data from Multiple Components

// Inside sending component
    pubsub.fire("Notify", "sendNotification", {
        name: "Notify",
        value: // payload
    });

    // Inside receving component 1
    pubsub.register("Notify", {
        sendNotification: //Do something
    });

    // Inside receving component 2
    pubsub.register("Notify", {
        sendNotification: //Do something else
    });