@solidjs/signals 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.js +58 -30
- package/dist/node.cjs +220 -192
- package/dist/prod.js +219 -191
- package/dist/types/core/core.d.ts +10 -2
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/signals.d.ts +7 -19
- package/package.json +1 -1
|
@@ -51,7 +51,7 @@ interface ObserverType {
|
|
|
51
51
|
/**
|
|
52
52
|
* Returns the current observer.
|
|
53
53
|
*/
|
|
54
|
-
export declare function getObserver():
|
|
54
|
+
export declare function getObserver(): Computation | null;
|
|
55
55
|
export declare const UNCHANGED: unique symbol;
|
|
56
56
|
export type UNCHANGED = typeof UNCHANGED;
|
|
57
57
|
export declare class Computation<T = any> extends Owner implements SourceType, ObserverType {
|
|
@@ -142,12 +142,20 @@ export declare function hasUpdated(fn: () => any): boolean;
|
|
|
142
142
|
/**
|
|
143
143
|
* Returns true if the given function contains async signals are out of date.
|
|
144
144
|
*/
|
|
145
|
-
export declare function
|
|
145
|
+
export declare function isPending(fn: () => any): boolean;
|
|
146
|
+
export declare function isPending(fn: () => any, loadingValue: boolean): boolean;
|
|
146
147
|
/**
|
|
147
148
|
* Attempts to resolve value of expression synchronously returning the last resolved value for any async computation.
|
|
148
149
|
*/
|
|
149
150
|
export declare function latest<T>(fn: () => T): T;
|
|
151
|
+
export declare function latest<T, U>(fn: () => T, fallback: U): T | U;
|
|
150
152
|
export declare function catchError(fn: () => void): unknown | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Runs the given function in the given observer.
|
|
155
|
+
*
|
|
156
|
+
* Warning: Usually there are simpler ways of modeling a problem that avoid using this function
|
|
157
|
+
*/
|
|
158
|
+
export declare function runWithObserver<T>(observer: Computation, run: () => T): T | undefined;
|
|
151
159
|
/**
|
|
152
160
|
* A convenient wrapper that calls `compute` with the `owner` and `observer` and is guaranteed
|
|
153
161
|
* to reset the global context after the computation is finished even if an error is thrown.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ContextNotFoundError, NoOwnerError, NotReadyError, type ErrorHandler } from "./error.js";
|
|
2
2
|
export { Owner, createContext, getContext, setContext, hasContext, getOwner, onCleanup, type Context, type ContextRecord, type Disposable } from "./owner.js";
|
|
3
|
-
export { Computation, createBoundary, getObserver, isEqual, untrack, hasUpdated,
|
|
3
|
+
export { Computation, createBoundary, getObserver, isEqual, untrack, hasUpdated, isPending, latest, catchError, UNCHANGED, compute, runWithObserver, type SignalOptions } from "./core.js";
|
|
4
4
|
export { Effect, EagerComputation } from "./effect.js";
|
|
5
5
|
export { flushSync, getClock, incrementClock, type IQueue, Queue } from "./scheduler.js";
|
|
6
6
|
export { createSuspense } from "./suspense.js";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, createContext, flatten, flushSync, createBoundary, getContext, setContext, hasContext, getOwner, onCleanup, getObserver, isEqual, untrack, hasUpdated,
|
|
1
|
+
export { Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, createContext, flatten, flushSync, createBoundary, getContext, setContext, hasContext, getOwner, onCleanup, getObserver, isEqual, untrack, hasUpdated, isPending, latest, catchError, runWithObserver, createSuspense, SUPPORTS_PROXY } from "./core/index.js";
|
|
2
2
|
export type { ErrorHandler, SignalOptions, Context, ContextRecord, Disposable, IQueue } from "./core/index.js";
|
|
3
3
|
export { mapArray, repeat, type Maybe } from "./map.js";
|
|
4
4
|
export * from "./signals.js";
|
package/dist/types/signals.d.ts
CHANGED
|
@@ -12,8 +12,10 @@ export type ComputeFunction<Prev, Next extends Prev = Prev> = (v: Prev) => Next;
|
|
|
12
12
|
export type EffectFunction<Prev, Next extends Prev = Prev> = (v: Next, p?: Prev) => (() => void) | void;
|
|
13
13
|
export interface EffectOptions {
|
|
14
14
|
name?: string;
|
|
15
|
+
defer?: boolean;
|
|
15
16
|
}
|
|
16
|
-
export interface MemoOptions<T>
|
|
17
|
+
export interface MemoOptions<T> {
|
|
18
|
+
name?: string;
|
|
17
19
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
18
20
|
}
|
|
19
21
|
export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
|
|
@@ -95,7 +97,7 @@ export declare function createAsync<T>(compute: (prev?: T) => Promise<T> | Async
|
|
|
95
97
|
* @description https://docs.solidjs.com/reference/basic-reactivity/create-effect
|
|
96
98
|
*/
|
|
97
99
|
export declare function createEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effect: EffectFunction<NoInfer<Next>, Next>, error?: (err: unknown) => void): void;
|
|
98
|
-
export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next>, error: (err: unknown) => void | undefined, value: Init, options?: EffectOptions): void;
|
|
100
|
+
export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next>, error: ((err: unknown) => void) | undefined, value: Init, options?: EffectOptions): void;
|
|
99
101
|
/**
|
|
100
102
|
* Creates a reactive computation that runs during the render phase as DOM elements are created and updated but not necessarily connected
|
|
101
103
|
* ```typescript
|
|
@@ -125,11 +127,12 @@ export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFu
|
|
|
125
127
|
*/
|
|
126
128
|
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T)): T;
|
|
127
129
|
/**
|
|
128
|
-
* Runs the given function in the given owner
|
|
130
|
+
* Runs the given function in the given owner to move ownership of nested primitives and cleanups.
|
|
131
|
+
* This method untracks the current scope.
|
|
129
132
|
*
|
|
130
133
|
* Warning: Usually there are simpler ways of modeling a problem that avoid using this function
|
|
131
134
|
*/
|
|
132
|
-
export declare function runWithOwner<T>(owner: Owner | null, run: () => T): T
|
|
135
|
+
export declare function runWithOwner<T>(owner: Owner | null, run: () => T): T;
|
|
133
136
|
/**
|
|
134
137
|
* Switches to fallback whenever an error is thrown within the context of the child scopes
|
|
135
138
|
* @param fn boundary for the error
|
|
@@ -145,18 +148,3 @@ export declare function createErrorBoundary<T, U>(fn: () => T, fallback: (error:
|
|
|
145
148
|
* @param fn a reactive expression to resolve
|
|
146
149
|
*/
|
|
147
150
|
export declare function resolve<T>(fn: () => T): Promise<T>;
|
|
148
|
-
/**
|
|
149
|
-
* Creates a reactive computation that runs after the render phase with flexible tracking
|
|
150
|
-
* ```typescript
|
|
151
|
-
* export function createReaction(
|
|
152
|
-
* effect: () => void,
|
|
153
|
-
* options?: { name?: string }
|
|
154
|
-
* ): (fn: () => void) => void;
|
|
155
|
-
* ```
|
|
156
|
-
* @param effect a function that is called when tracked function is invalidated.
|
|
157
|
-
* @param error an optional function that receives an error if thrown during tracking
|
|
158
|
-
* @param options allows to set a name in dev mode for debugging purposes
|
|
159
|
-
*
|
|
160
|
-
* @description https://docs.solidjs.com/reference/secondary-primitives/create-reaction
|
|
161
|
-
*/
|
|
162
|
-
export declare function createReaction(effect: () => (() => void) | void, error?: (err: unknown) => (() => void) | void, options?: EffectOptions): (tracking: () => void) => void;
|