UNPKG

dreamstate

Version:

Store management library based on react context and observers

1 lines 601 B
import{DreamstateError as t}from"../error/DreamstateError.js";import{EDreamstateErrorCode as e}from"../../types/error.js";import{isCorrectSignalType as r}from"../../utils/typechecking.js";function o(){return this.canceled=!0,this}function n(n,c,i){if(void 0===c&&(c=null),!n||!r(n.type))throw new t(e.INCORRECT_SIGNAL_TYPE);var a={type:n.type,data:n.data,emitter:c,timestamp:Date.now(),cancel:o};return i.SIGNAL_LISTENERS_REGISTRY.forEach((function(t){try{a.canceled||t(a)}catch(t){console.error("[DS]","Failed to proceed emitted signal (".concat(String(n.type),"):"),t)}})),a}export{n as emitSignal};