Subscribe

Overview

Use the subscribe method to subscribe to related action sets, and when the subscribed action is triggered, the corresponding message function will be executed.

Rated APIs

NameDescriptionReturn value
subscribeMessage execution subscribing specific method setvoid
unsubscribeSubscription event of clearing specific method setvoid

Parameter description:

NameDescriptionType
ACTIONMethod setACTION
callBackFunctionCallback function for completed action completionFunction
Note

Since subscription events are globally available and can be subscribed to in multiple places, if the same type of subscription scenario is consumed in any function, all previously subscribed subscription events of the same type will also be consumed.

Actions

ACTIONDescription
MESSAGEOpen message
OPEN_MODALOpen pop-up window
MODAL_SAVEPop-up window & save
MODAL_CLOSEPop-up window & cancel
REDIRECTNavigation redirection
ROUTER_REDIRECTRouter navigation redirection
ROUTER_TO_SPECIFIED_PAGEJump to specific resource page

Code example

import { Modal } from '@shoplinedev/appbridge'
Modal.create(app).subscribe(Modal.ACTION.MODAL_SAVE, () => {
// do someting
console.log('modal has saved')
)
Modal.create(app).unsubscribe(ACTION.MODAL_SAVE)
Was this article helpful to you?

Error loading component.

Error loading component.