This is an old documentation. Go to the latest Customer's Canvas docs

subscribe Method

Callable

  • subscribe(event: string, handler: function ) : void
  • Links an event with a handler function. PostMessage.Events object contains the supported events.

    example

    The following snippet subscribes to the Events.BoundsNotification event and outputs the event arguments to the console:

    var editor = null;
    CustomersCanvas.IframeApi.loadEditor(iframe, productDefinition)
        .then((e) => {
            editor = e;
            editor.subscribe(CustomersCanvas.IframeApi.PostMessage.Events.BoundsNotification, (args) => {
                    console.log("BoundsNotification fired."); 
                    console.log(JSON.stringify(args, null, 4)); 
                });
            editor.subscribe(CustomersCanvas.IframeApi.PostMessage.Events.PrintAreaBoundsChanged, (args) => {
                    console.log("PrintAreaBoundsChanged");
                    console.log(args);
                });
        });
    

    Parameters

    • event: string

      The event to link the handler function with.

    • handler: function

      The handler function to link with the given event.

        • ( ...args: any [] ) : void
        • Parameters

          • Rest ...args: any []

          Returns void

    Returns void