Last active
August 20, 2019 21:53
-
-
Save hannachen/b99ffc7bbc1a47ef89460170bc1bd127 to your computer and use it in GitHub Desktop.
App Bridge Modal vs EASDK Modal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Modal} from '@shopify/app-bridge/actions'; | |
const modalOptions = { | |
title: 'My Modal', | |
message: 'Hello world!', | |
}; | |
const closeModalCallback = function() { | |
console.log('Modal was closed!'); | |
} | |
// EASDK - create modal, attach callback, open modal, all in one call: | |
// ShopifyApp.Modal.alert(modalOptions, closeModalCallback); | |
// App Bridge - broken down into smaller steps: | |
const myModal = Modal.create(app, modalOptions); // create modal | |
myModal.subscribe(Modal.Action.CLOSE, closeModalCallback); // attach callback | |
myModal.dispatch(Modal.Action.OPEN); // open modal | |
myModal.set({title: 'My New Modal'}); // update title |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment