Comparing version 0.5.29 to 0.5.30
@@ -24,4 +24,4 @@ import { FC } from 'react'; | ||
watch: { | ||
(listener: (value: T, prev?: T) => void): () => void; | ||
once(listener: (value: T, prev?: T) => void): () => void; | ||
(listener: (value: T, prev: T) => void): () => void; | ||
once(listener: (value: T, prev: T) => void): () => void; | ||
}; | ||
@@ -39,4 +39,4 @@ flow: { | ||
sub: { | ||
<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void; | ||
once<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void; | ||
<S>(reactionable: Reactionable<S>, fn: (data: K, value: S, prev: S) => T): () => void; | ||
once<S>(reactionable: Reactionable<S>, fn: (data: K, value: S, prev: S) => T): () => void; | ||
}; | ||
@@ -56,4 +56,4 @@ set(value: T): void; | ||
watch: { | ||
(listener: (value: K, prev?: K) => void): () => void; | ||
once(listener: (value: K, prev?: K) => void): () => void; | ||
(listener: (value: K, prev: K) => void): () => void; | ||
once(listener: (value: K, prev: K) => void): () => void; | ||
}; | ||
@@ -74,4 +74,4 @@ reset(): void; | ||
sub: { | ||
<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void; | ||
once<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void; | ||
<S>(reactionable: Reactionable<S>, fn: (data: K, value: S, prev: S) => T): () => void; | ||
once<S>(reactionable: Reactionable<S>, fn: (data: K, value: S, prev: S) => T): () => void; | ||
}; | ||
@@ -96,4 +96,4 @@ set(value: T): void; | ||
watch: { | ||
(listener: (value: K extends Ensurable<infer P> ? P : K, prev?: K) => void): () => void; | ||
once(listener: (value: K extends Ensurable<infer P> ? P : K, prev?: K) => void): () => void; | ||
(listener: (value: K extends Ensurable<infer P> ? P : K, prev: K) => void): () => void; | ||
once(listener: (value: K extends Ensurable<infer P> ? P : K, prev: K) => void): () => void; | ||
}; | ||
@@ -144,4 +144,4 @@ flow: { | ||
sub: { | ||
<S>(reactionable: Reactionable<S>, fn: (data?: boolean, value?: S, prev?: S) => void): () => void; | ||
once<S_1>(reactionable: Reactionable<S_1>, fn: (data?: boolean, value?: S_1, prev?: S_1) => void): () => void; | ||
<S>(reactionable: Reactionable<S>, fn: (data: boolean, value: S, prev: S) => void): () => void; | ||
once<S_1>(reactionable: Reactionable<S_1>, fn: (data: boolean, value: S_1, prev: S_1) => void): () => void; | ||
}; | ||
@@ -157,4 +157,4 @@ set(value: void): void; | ||
sub: { | ||
<S>(reactionable: Reactionable<S>, fn: (data?: boolean, value?: S, prev?: S) => void): () => void; | ||
once<S_1>(reactionable: Reactionable<S_1>, fn: (data?: boolean, value?: S_1, prev?: S_1) => void): () => void; | ||
<S>(reactionable: Reactionable<S>, fn: (data: boolean, value: S, prev: S) => void): () => void; | ||
once<S_1>(reactionable: Reactionable<S_1>, fn: (data: boolean, value: S_1, prev: S_1) => void): () => void; | ||
}; | ||
@@ -181,3 +181,3 @@ set(value: void): void; | ||
declare function effect(fn: () => () => any): () => any; | ||
declare function un(unsub: () => void): (() => void); | ||
declare function un(unsub: () => void): () => void; | ||
declare function cycle(body: () => void): () => void; | ||
@@ -184,0 +184,0 @@ declare function isolate(): () => () => void; |
@@ -219,3 +219,3 @@ "use strict"; | ||
const f = target.then ? signal() : value(); | ||
on(target, (v) => { | ||
on(target, v => { | ||
if (fn(v)) | ||
@@ -222,0 +222,0 @@ f(v); |
{ | ||
"name": "realar", | ||
"version": "0.5.29", | ||
"version": "0.5.30", | ||
"description": "React state manager", | ||
@@ -30,3 +30,3 @@ "repository": { | ||
"dependencies": { | ||
"reactive-box": "0.6.5" | ||
"reactive-box": "0.6.6" | ||
}, | ||
@@ -89,3 +89,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "dd12a2af73d3b11530dc0e0ec4325c993577a020" | ||
"gitHead": "2157dc3f49b9aafc23ea23f2e16ba1f1481aa105" | ||
} |
@@ -107,9 +107,9 @@ import React, { Context, FC } from 'react'; | ||
watch: { | ||
(listener: (value: T, prev?: T) => void): () => void; | ||
once(listener: (value: T, prev?: T) => void): () => void; | ||
(listener: (value: T, prev: T) => void): () => void; | ||
once(listener: (value: T, prev: T) => void): () => void; | ||
}; | ||
flow: { | ||
filter(fn: (data: T) => any): Value<T, Ensurable<T>> | ||
} | ||
filter(fn: (data: T) => any): Value<T, Ensurable<T>>; | ||
}; | ||
}; | ||
@@ -125,4 +125,4 @@ | ||
sub: { | ||
<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void; | ||
once<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void; | ||
<S>(reactionable: Reactionable<S>, fn: (data: K, value: S, prev: S) => T): () => void; | ||
once<S>(reactionable: Reactionable<S>, fn: (data: K, value: S, prev: S) => T): () => void; | ||
}; | ||
@@ -138,3 +138,3 @@ set(value: T): void; | ||
filter(fn: (data: T) => any): Value<T, K>; | ||
} | ||
}; | ||
@@ -145,4 +145,4 @@ view<P>(get: (data: K) => P): Value<T, P>; | ||
watch: { | ||
(listener: (value: K, prev?: K) => void): () => void; | ||
once(listener: (value: K, prev?: K) => void): () => void; | ||
(listener: (value: K, prev: K) => void): () => void; | ||
once(listener: (value: K, prev: K) => void): () => void; | ||
}; | ||
@@ -152,4 +152,4 @@ reset(): void; | ||
flow: { | ||
filter(fn: (data: K) => any): Value<K, Ensurable<T>> | ||
} | ||
filter(fn: (data: K) => any): Value<K, Ensurable<T>>; | ||
}; | ||
} & { | ||
@@ -160,15 +160,20 @@ [P in Exclude<keyof Array<void>, number>]: never; | ||
type Signal<T, K = T, X = {}, E = { | ||
reset(): void; | ||
update: (fn: (state: K) => T) => void; | ||
sub: { | ||
<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void; | ||
once<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void; | ||
}; | ||
set(value: T): void; | ||
}> = Callable<T> & | ||
type Signal< | ||
T, | ||
K = T, | ||
X = {}, | ||
E = { | ||
reset(): void; | ||
update: (fn: (state: K) => T) => void; | ||
sub: { | ||
<S>(reactionable: Reactionable<S>, fn: (data: K, value: S, prev: S) => T): () => void; | ||
once<S>(reactionable: Reactionable<S>, fn: (data: K, value: S, prev: S) => T): () => void; | ||
}; | ||
set(value: T): void; | ||
} | ||
> = Callable<T> & | ||
Pick<Promise<T>, 'then' | 'catch' | 'finally'> & { | ||
0: () => K; | ||
1: (value: T) => void; | ||
readonly val: K | ||
readonly val: K; | ||
get(): K; | ||
@@ -183,3 +188,3 @@ } & { | ||
filter(fn: (data: T) => any): Signal<T, K, X, E>; | ||
} | ||
}; | ||
@@ -191,9 +196,9 @@ view<P>(get: (data: K) => P): Signal<T, P, X, E>; | ||
watch: { | ||
(listener: (value: K extends Ensurable<infer P> ? P : K, prev?: K) => void): () => void; | ||
once(listener: (value: K extends Ensurable<infer P> ? P : K, prev?: K) => void): () => void; | ||
(listener: (value: K extends Ensurable<infer P> ? P : K, prev: K) => void): () => void; | ||
once(listener: (value: K extends Ensurable<infer P> ? P : K, prev: K) => void): () => void; | ||
}; | ||
flow: { | ||
filter(fn: (data: K) => any): Signal<K, Ensurable<T>> | ||
} | ||
filter(fn: (data: K) => any): Signal<K, Ensurable<T>>; | ||
}; | ||
} & E & | ||
@@ -313,3 +318,10 @@ X & | ||
function def_format(ctx: any, get: any, set?: any, no_update?: any, readonly_val?: any, has_to?: any) { | ||
function def_format( | ||
ctx: any, | ||
get: any, | ||
set?: any, | ||
no_update?: any, | ||
readonly_val?: any, | ||
has_to?: any | ||
) { | ||
if (!Array.isArray(ctx)) { | ||
@@ -334,3 +346,4 @@ ctx[Symbol.iterator] = function* () { | ||
ctx.sub = (s: any, fn: any) => on(s, (v, v_prev) => set(fn ? fn(get(), v, v_prev) : void 0)); | ||
ctx.sub.once = (s: any, fn: any) => once(s, (v, v_prev) => set(fn ? fn(get(), v, v_prev) : void 0)); | ||
ctx.sub.once = (s: any, fn: any) => | ||
once(s, (v, v_prev) => set(fn ? fn(get(), v, v_prev) : void 0)); | ||
} | ||
@@ -430,3 +443,3 @@ def_prop(ctx, key, val_prop); | ||
const f = (target as any).then ? signal<T>() : value<T>(); | ||
on(target, (v) => { | ||
on(target, v => { | ||
if (fn(v)) f(v); | ||
@@ -552,3 +565,3 @@ }); | ||
function un(unsub: () => void): (() => void) { | ||
function un(unsub: () => void): () => void { | ||
if (unsub && context_unsubs) context_unsubs.push(unsub); | ||
@@ -555,0 +568,0 @@ return unsub; |
Sorry, the diff of this file is not supported yet
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
1395
75415
+ Addedreactive-box@0.6.6(transitive)
- Removedreactive-box@0.6.5(transitive)
Updatedreactive-box@0.6.6