UNPKG

patronum

Version:

☄️ Effector utility library delivering modularity and convenience

37 lines (36 loc) 828 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.time = time; var _effector = require("effector"); const defaultNow = () => Date.now(); function time(args) { const argsShape = _effector.is.unit(args) ? { clock: args } : args; const { clock, getNow, initial } = argsShape; const timeReader = getNow !== null && getNow !== void 0 ? getNow : defaultNow; const readNowFx = (0, _effector.createEffect)(timeReader, { name: "readNowFx", sid: "ito90c" }); const $time = (0, _effector.restore)(readNowFx, initial !== null && initial !== void 0 ? initial : timeReader(), { name: "$time", sid: "-k3vl4d" }); (0, _effector.sample)({ and: [{ clock, target: readNowFx }], or: { sid: "rul0o2" } }); return $time; }