@action-land/component
Version:
Basic interface for a component
15 lines (14 loc) • 851 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const component_1 = require("@action-land/component");
const core_1 = require("@action-land/core");
const tarz_1 = require("@action-land/tarz");
exports.AutoForward = (spec) => (component) => component_1.COM((...t) => {
return Object.assign({ '@@forward': { keys: Object.keys(spec) } }, component.init(...t));
}, tarz_1.concatR((action, state) => Object.assign({}, state, {
[action.type]: spec[action.type]
? spec[action.type].update(action.value, state[action.type])
: state[action.type]
}), component.update), tarz_1.concatC((act, state) => core_1.isAction(act) && !core_1.Action.isNil(act) && spec[act.type]
? core_1.action(act.type, spec[act.type].command(act.value, state[act.type]))
: core_1.Nil(), component.command), component.view);