@shopify/app-bridge-core
Version:
**[Join our team and work on libraries like this one.](https://www.shopify.ca/careers)**
55 lines (52 loc) • 1.41 kB
JavaScript
import { actionWrapper } from '../../helper.js';
import { ActionSet } from '../../ActionSet.js';
import { Group } from '../../types.js';
import { Action as Action$1 } from '../index.js';
var Action;
(function (Action) {
Action["LOADING"] = "LOADING";
Action["LOADED"] = "LOADED";
})(Action || (Action = {}));
/**
* A set of Actions for updating the modal component
* @public
*/
class ModalContent extends ActionSet {
constructor(app, options) {
super(app, Group.Modal, Group.Modal, options ? options.id : undefined);
}
loaded() {
this.dispatch(Action.LOADED);
}
loading() {
this.dispatch(Action.LOADING);
}
/**
* @private
*/
dispatch(action) {
switch (action) {
case Action.LOADED:
this.dispatchModalAction(Action$1.UPDATE_CONTENT, { loading: false });
break;
case Action.LOADING:
this.dispatchModalAction(Action$1.UPDATE_CONTENT, { loading: true });
break;
}
return this;
}
/**
* @internal
*/
async dispatchModalAction(type, payload) {
const updateAction = actionWrapper({
type,
group: Group.Modal,
payload: {
...payload,
},
});
this.app.dispatch(updateAction);
}
}
export { Action, ModalContent };