@shopify/app-bridge-host
Version:
App Bridge Host contains components and middleware to be consumed by the app's host, as well as the host itself. The middleware and `Frame` component are responsible for facilitating communication between the client and host, and used to act on actions se
37 lines (33 loc) • 1.03 kB
JavaScript
;
var Actions = require('@shopify/app-bridge-core/actions');
var leaveConfirmation = require('@shopify/app-bridge-core/validate/actions/leaveConfirmation');
var defaultStore = null;
function reducer(state, action) {
if (state === void 0) { state = defaultStore; }
var castedAction = action;
if (leaveConfirmation.validateAction(castedAction)) {
return state;
}
switch (action.type) {
case Actions.LeaveConfirmation.Action.ENABLE: {
var id = action.payload.id;
return { id: id };
}
case Actions.LeaveConfirmation.Action.DISABLE:
return null;
default:
return state;
}
}
var feature = {
actions: {
enable: Actions.LeaveConfirmation.enable,
disable: Actions.LeaveConfirmation.disable,
confirm: Actions.LeaveConfirmation.confirm,
},
key: 'leaveConfirmation',
initialState: defaultStore,
reducer: reducer,
};
exports.feature = feature;
exports.reducer = reducer;