UNPKG

dreamstate

Version:

Store management library based on react context and observers

1 lines 722 B
import{DreamstateError as r}from"../error/DreamstateError.js";import{QUERY_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{isCorrectQueryType as s}from"../../utils/typechecking.js";function a(a){if(!s(a))throw new r(o.INCORRECT_QUERY_TYPE,typeof a);return n((function(n,s){if(!(s.prototype instanceof t))throw new r(o.TARGET_CONTEXT_MANAGER_EXPECTED,"Only ContextManager extending classes methods can be decorated as query handlers.");e.has(s)?e.get(s).push([n,a]):e.set(s,[[n,a]])}))}export{a as OnQuery};