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
Name | Description | Return value |
---|---|---|
subscribe | Message execution subscribing specific method set | void |
unsubscribe | Subscription event of clearing specific method set | void |
Parameter description:
Name | Description | Type |
---|---|---|
ACTION | Method set | ACTION |
callBackFunction | Callback function for completed action completion | Function |
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
ACTION | Description |
---|---|
MESSAGE | Open message |
OPEN_MODAL | Open pop-up window |
MODAL_SAVE | Pop-up window & save |
MODAL_CLOSE | Pop-up window & cancel |
REDIRECT | Navigation redirection |
ROUTER_REDIRECT | Router navigation redirection |
ROUTER_TO_SPECIFIED_PAGE | Jump 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.