UNPKG

dreamstate

Version:

Store management library based on react context and observers

1 lines 873 B
import{DreamstateError as r}from"../error/DreamstateError.js";import{SIGNAL_METADATA_REGISTRY as e}from"../internals.js";import{ContextManager as t}from"../management/ContextManager.js";import{EDreamstateErrorCode as o}from"../../types/error.js";import{createMethodDecorator as n}from"../../utils/polyfills/createMethodDecorator.js";import{isCorrectSignalType as s}from"../../utils/typechecking.js";function a(a){if(Array.isArray(a)?0===a.length||a.some((function(r){return!s(r)})):!s(a))throw new r(o.INCORRECT_PARAMETER,"Unexpected signal type provided, expected symbol, string, number or array of it. Got: ".concat(typeof a,"."));return n((function(n,s){if(!(s.prototype instanceof t))throw new r(o.INCORRECT_PARAMETER,"Only ContextManager extending classes methods can be decorated as handlers.");e.has(s)?e.get(s).push([n,a]):e.set(s,[[n,a]])}))}export{a as OnSignal};