deep-state-observer
Advanced tools
Comparing version 4.0.3 to 4.0.4
@@ -136,2 +136,7 @@ export interface PathInfo { | ||
} | ||
export interface Bulk { | ||
path: string; | ||
value: unknown; | ||
params: Params; | ||
} | ||
export interface Multi { | ||
@@ -144,3 +149,3 @@ update: (updatePath: string, fn: Updater | any, options?: UpdateOptions) => Multi; | ||
declare type PossiblePath<T> = PathImpl<T, keyof T> | keyof T | string; | ||
declare type PathValue<T, P extends PossiblePath<T>> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? Rest extends PossiblePath<T[K]> ? PathValue<T[K], Rest> : any : any : P extends keyof T ? T[P] : any; | ||
declare type PathValue<T, P extends PossiblePath<T>> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? Rest extends PossiblePath<T[K]> ? PathValue<T[K], Rest> : any & Bulk[] : any & Bulk[] : P extends keyof T ? T[P] & Bulk[] : any & Bulk[]; | ||
export interface UnknownObject { | ||
@@ -233,3 +238,3 @@ [key: string]: unknown; | ||
isMutedListener(listenerFunc: ListenerFunction<PathValue<T, PossiblePath<T>>>): boolean; | ||
mute(pathOrListenerFunction: string | ListenerFunction<PathValue<T, PossiblePath<T>>>): Set<ListenerFunction<(string extends keyof T ? T[keyof T & string] : any) | PathValue<T, keyof T> | PathValue<T, PathImpl<T, keyof T>>>>; | ||
mute(pathOrListenerFunction: string | ListenerFunction<PathValue<T, PossiblePath<T>>>): Set<ListenerFunction<(string extends keyof T ? T[keyof T & string] & Bulk[] : any) | PathValue<T, keyof T> | PathValue<T, PathImpl<T, keyof T>>>>; | ||
unmute(pathOrListenerFunction: string | ListenerFunction<PathValue<T, PossiblePath<T>>>): boolean; | ||
@@ -236,0 +241,0 @@ private debugSubscribe; |
22
index.ts
@@ -167,2 +167,8 @@ import WildcardObject from "./wildcard-object-scan"; | ||
export interface Bulk { | ||
path: string; | ||
value: unknown; | ||
params: Params; | ||
} | ||
const defaultUpdateOptions: UpdateOptions = { | ||
@@ -196,7 +202,7 @@ only: [], | ||
? PathValue<T[K], Rest> | ||
: any | ||
: any | ||
: any & Bulk[] | ||
: any & Bulk[] | ||
: P extends keyof T | ||
? T[P] | ||
: any; | ||
? T[P] & Bulk[] | ||
: any & Bulk[]; | ||
@@ -704,3 +710,3 @@ function log(message: string, info: any) { | ||
const paths = this.scan.get(cleanPath); | ||
const bulkValue = []; | ||
const bulkValue: Bulk[] = []; | ||
for (const path in paths) { | ||
@@ -828,3 +834,3 @@ if (this.isMuted(path)) continue; | ||
const time = this.debugTime(bulkListener); | ||
const bulkValue = []; | ||
const bulkValue: Bulk[] = []; | ||
for (const bulk of bulkListener.value) { | ||
@@ -893,3 +899,3 @@ bulkValue.push({ ...bulk, value: bulk.value() }); | ||
const value = traverse ? () => this.get(cutPath) : () => newValue; | ||
const bulkValue = [{ value, path: updatePath, params }]; | ||
const bulkValue: Bulk[] = [{ value, path: updatePath, params }]; | ||
for (const listener of listenersCollection.listeners.values()) { | ||
@@ -992,3 +998,3 @@ if (this.shouldIgnore(listener, updatePath)) { | ||
: undefined; | ||
const bulk = []; | ||
const bulk: Bulk[] = []; | ||
const bulkListeners = {}; | ||
@@ -995,0 +1001,0 @@ for (const currentRestPath in wildcardNewValues) { |
{ | ||
"name": "deep-state-observer", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"description": "Deep state observer is an state management library that will fire listeners only when specified object node (which also can be a wildcard) was changed.", | ||
@@ -5,0 +5,0 @@ "main": "index.cjs.js", |
@@ -1581,3 +1581,3 @@ /*! ***************************************************************************** | ||
const state = new DeepState(someState); | ||
state.subscribe("y.c", (v) => { }); | ||
state.subscribe("y.c", (v) => { }, { bulk: true }); | ||
state.$$$.y.c.d = 33; | ||
@@ -1584,0 +1584,0 @@ if (state.get("y.c.d") !== 33) { |
@@ -39,3 +39,3 @@ import * as path from "path"; | ||
state.subscribe("y.c", (v) => {}); | ||
state.subscribe("y.c", (v) => {}, { bulk: true }); | ||
@@ -42,0 +42,0 @@ state.$$$.y.c.d = 33; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
525531
12961