@shopify/app-bridge-core
Version:
**[Join our team and work on libraries like this one.](https://www.shopify.ca/careers)**
46 lines (43 loc) • 1.17 kB
JavaScript
import { actionWrapper } from '../../helper.js';
import { ActionSet } from '../../ActionSet.js';
import { Group } from '../../types.js';
var Action;
(function (Action) {
Action["PUSH"] = "APP::NAVIGATION::HISTORY::PUSH";
Action["REPLACE"] = "APP::NAVIGATION::HISTORY::REPLACE";
})(Action || (Action = {}));
function push(payload) {
return actionWrapper({
payload,
group: Group.Navigation,
type: Action.PUSH,
});
}
function replace(payload) {
return actionWrapper({
payload,
group: Group.Navigation,
type: Action.REPLACE,
});
}
class History extends ActionSet {
constructor(app) {
super(app, 'History', Group.Navigation);
}
get payload() {
return { id: this.id };
}
dispatch(type, path) {
const payload = { ...this.payload, path };
switch (type) {
case Action.PUSH:
this.app.dispatch(push(payload));
break;
case Action.REPLACE:
this.app.dispatch(replace(payload));
break;
}
return this;
}
}
export { Action, History, push, replace };