@gongt/ts-stl-client
Version:
44 lines • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class ReduxAction {
constructor(payload, VirtualStore) {
this.type = this.constructor.name;
this.payload = payload || null;
if (VirtualStore) {
if (typeof VirtualStore === 'string') {
this.virtualStorage = VirtualStore;
}
else {
this.virtualStorage = VirtualStore.name;
}
if (!this.virtualStorage) {
throw new TypeError('Action `' + this.type + '`: invalid virtualStorage');
}
}
else {
this.virtualStorage = null;
}
}
static is(act) {
return act.type === this.name;
}
static compare(act, Action, VirtualStore) {
if (VirtualStore) {
return act && act.virtualStorage
&& act.type === Action.name
&& act.virtualStorage === VirtualStore.name;
}
else {
return act && act.type === Action.name;
}
}
toJSON() {
return {
type: this.type,
virtualStorage: this.virtualStorage,
payload: this.payload,
};
}
}
exports.ReduxAction = ReduxAction;
//# sourceMappingURL=action.js.map