@storex/core
Advanced tools
Comparing version 1.0.27 to 1.0.28
@@ -27,5 +27,5 @@ export interface dependenceDispatcher { | ||
constructor({ events, dependencies }?: DispatcherArgs); | ||
static register(func: any, dispatcher: (Dispatcher | DispatcherRegisterOptions)[]): void; | ||
static register(func: any, dispatchers: (Dispatcher | DispatcherRegisterOptions)[]): void; | ||
dispatchOnce: (func: any) => Promise<void>; | ||
static unregister(func: any, dispatcher: (Dispatcher | DispatcherRegisterOptions)[]): void; | ||
static unregister(func: any, dispatchers: (Dispatcher | DispatcherRegisterOptions)[]): void; | ||
_sentOnChange: () => this; | ||
@@ -32,0 +32,0 @@ register: (func: (a: this) => any, eventNames?: string[]) => void; |
@@ -50,3 +50,3 @@ "use strict"; | ||
}; | ||
this.unregisterFromAll = (func) => { | ||
this.unregisterFromAll = func => { | ||
for (const event of Object.keys(this._eventsRegisterFunc)) { | ||
@@ -75,8 +75,10 @@ this._eventsRegisterFunc[event].delete(func); | ||
} | ||
static register(func, dispatcher) { | ||
for (const val of dispatcher) { | ||
if (val instanceof Dispatcher) { | ||
static register(func, dispatchers) { | ||
const dis = dispatchers; | ||
for (const key in dis) { | ||
const val = dis[key]; | ||
if (val && val.dispatch && val.register) { | ||
val.register(func); | ||
} | ||
else if (val || val.dispatcher instanceof Dispatcher) { | ||
else if (val || (val.dispatcher.dispatch && val.dispatcher.register)) { | ||
val.dispatcher.register(func, val.on); | ||
@@ -89,8 +91,11 @@ } | ||
} | ||
static unregister(func, dispatcher) { | ||
for (const val of dispatcher) { | ||
if (val instanceof Dispatcher) { | ||
static unregister(func, dispatchers) { | ||
const dis = dispatchers; | ||
for (const key in dis) { | ||
const val = dis[key]; | ||
if (val && val.dispatch && val.unregister) { | ||
val.unregister(func); | ||
} | ||
else if (val || val.dispatcher instanceof Dispatcher) { | ||
else if (val || | ||
(val.dispatcher.dispatch && val.dispatcher.unregister)) { | ||
val.dispatcher.unregister(func, val.on); | ||
@@ -139,3 +144,2 @@ } | ||
this._waited_to_update_events = new Set(); | ||
//}, 0); | ||
} | ||
@@ -142,0 +146,0 @@ } |
export * from "./dispatcher"; | ||
export * from "./subscriber"; | ||
export * from "./subscribe"; | ||
export * from "./dispatch"; | ||
export * from "./wrappers"; |
@@ -7,3 +7,5 @@ "use strict"; | ||
__export(require("./dispatcher")); | ||
__export(require("./subscriber")); | ||
__export(require("./subscribe")); | ||
__export(require("./dispatch")); | ||
__export(require("./wrappers")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const wrappers_1 = require("./core/wrappers"); | ||
let counter = 0; | ||
let obj = { name: "moshe" }; | ||
const store = wrappers_1.wrapObject(obj); | ||
store.register(() => counter++); | ||
store.context.name = "name"; | ||
store.context.age = 45; | ||
const sub_ins_1 = require("./core/sub-ins"); | ||
const dep1 = new sub_ins_1.DepIns(); | ||
sub_ins_1.des1.dispatch(); | ||
sub_ins_1.des1.dispatch(); | ||
sub_ins_1.des1.dispatch(); | ||
console.log(dep1.count1); |
{ | ||
"name": "@storex/core", | ||
"version": "1.0.27", | ||
"version": "1.0.28", | ||
"description": "Binding store to your app", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
24195
27
660