UNPKG

flux-action-class

Version:

Boilerplate free class-based action creator. Following flux-standard-action spec. Built with TypeScript.

29 lines (28 loc) 741 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.prefixDefault = 'flux-action-class:'; exports.setPrefix = (newPrefix) => { exports.prefixDefault = newPrefix; }; class ActionStandard { constructor(...args) { const payload = args[0]; const meta = args[1]; return { error: payload instanceof Error, meta, payload, type: this.constructor.type, }; } static get prefixFinal() { if (this.prefix) { return this.prefix; } return exports.prefixDefault; } static get type() { return `${this.prefixFinal}${this.name}`; } } exports.ActionStandard = ActionStandard;