Skip to content

Instantly share code, notes, and snippets.

@hannachen
Last active August 20, 2019 21:53
Show Gist options
  • Save hannachen/b99ffc7bbc1a47ef89460170bc1bd127 to your computer and use it in GitHub Desktop.
Save hannachen/b99ffc7bbc1a47ef89460170bc1bd127 to your computer and use it in GitHub Desktop.
App Bridge Modal vs EASDK Modal
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