solid-js 1.3.0-rc.3 → 1.3.0-rc.4
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.cjs +20 -7
- package/dist/dev.js +20 -8
- package/dist/server.cjs +6 -0
- package/dist/server.js +6 -1
- package/dist/solid.cjs +20 -7
- package/dist/solid.js +20 -8
- package/package.json +2 -2
- package/types/index.d.ts +1 -1
- package/types/reactive/signal.d.ts +17 -3
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -0
package/dist/dev.cjs
CHANGED
|
@@ -170,14 +170,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
170
170
|
if (owner) root.name = `${owner.name}-r${rootCount++}`;
|
|
171
171
|
Owner = root;
|
|
172
172
|
Listener = null;
|
|
173
|
-
let result;
|
|
174
173
|
try {
|
|
175
|
-
runUpdates(() =>
|
|
174
|
+
return runUpdates(() => fn(() => cleanNode(root)), true);
|
|
176
175
|
} finally {
|
|
177
176
|
Listener = listener;
|
|
178
177
|
Owner = owner;
|
|
179
178
|
}
|
|
180
|
-
return result;
|
|
181
179
|
}
|
|
182
180
|
function createSignal(value, options) {
|
|
183
181
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -211,7 +209,21 @@ function createEffect(fn, value, options) {
|
|
|
211
209
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
212
210
|
if (s) c.suspense = s;
|
|
213
211
|
c.user = true;
|
|
214
|
-
Effects
|
|
212
|
+
Effects ? Effects.push(c) : queueMicrotask(() => updateComputation(c));
|
|
213
|
+
}
|
|
214
|
+
function createReaction(onInvalidate, options) {
|
|
215
|
+
let fn;
|
|
216
|
+
const c = createComputation(() => {
|
|
217
|
+
fn ? fn() : untrack(onInvalidate);
|
|
218
|
+
fn = undefined;
|
|
219
|
+
}, undefined, false, 0, options ),
|
|
220
|
+
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
221
|
+
if (s) c.suspense = s;
|
|
222
|
+
c.user = true;
|
|
223
|
+
return tracking => {
|
|
224
|
+
fn = tracking;
|
|
225
|
+
updateComputation(c);
|
|
226
|
+
};
|
|
215
227
|
}
|
|
216
228
|
function createMemo(fn, value, options) {
|
|
217
229
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -241,7 +253,7 @@ function createResource(source, fetcher, options) {
|
|
|
241
253
|
if (options.globalRefetch !== false) {
|
|
242
254
|
Resources || (Resources = new Set());
|
|
243
255
|
Resources.add(load);
|
|
244
|
-
onCleanup(() => Resources.delete(load));
|
|
256
|
+
Owner && onCleanup(() => Resources.delete(load));
|
|
245
257
|
}
|
|
246
258
|
const contexts = new Set(),
|
|
247
259
|
[s, set] = createSignal(options.initialValue),
|
|
@@ -352,7 +364,7 @@ function createResource(source, fetcher, options) {
|
|
|
352
364
|
}
|
|
353
365
|
let Resources;
|
|
354
366
|
function refetchResources(info) {
|
|
355
|
-
Resources && Resources.
|
|
367
|
+
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
356
368
|
}
|
|
357
369
|
function createDeferred(source, options) {
|
|
358
370
|
let t,
|
|
@@ -777,7 +789,7 @@ function runUpdates(fn, init) {
|
|
|
777
789
|
if (Effects) wait = true;else Effects = [];
|
|
778
790
|
ExecCount++;
|
|
779
791
|
try {
|
|
780
|
-
fn();
|
|
792
|
+
return fn();
|
|
781
793
|
} catch (err) {
|
|
782
794
|
handleError(err);
|
|
783
795
|
} finally {
|
|
@@ -1588,6 +1600,7 @@ exports.createContext = createContext;
|
|
|
1588
1600
|
exports.createDeferred = createDeferred;
|
|
1589
1601
|
exports.createEffect = createEffect;
|
|
1590
1602
|
exports.createMemo = createMemo;
|
|
1603
|
+
exports.createReaction = createReaction;
|
|
1591
1604
|
exports.createRenderEffect = createRenderEffect;
|
|
1592
1605
|
exports.createResource = createResource;
|
|
1593
1606
|
exports.createRoot = createRoot;
|
package/dist/dev.js
CHANGED
|
@@ -166,14 +166,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
166
166
|
if (owner) root.name = `${owner.name}-r${rootCount++}`;
|
|
167
167
|
Owner = root;
|
|
168
168
|
Listener = null;
|
|
169
|
-
let result;
|
|
170
169
|
try {
|
|
171
|
-
runUpdates(() =>
|
|
170
|
+
return runUpdates(() => fn(() => cleanNode(root)), true);
|
|
172
171
|
} finally {
|
|
173
172
|
Listener = listener;
|
|
174
173
|
Owner = owner;
|
|
175
174
|
}
|
|
176
|
-
return result;
|
|
177
175
|
}
|
|
178
176
|
function createSignal(value, options) {
|
|
179
177
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -207,7 +205,21 @@ function createEffect(fn, value, options) {
|
|
|
207
205
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
208
206
|
if (s) c.suspense = s;
|
|
209
207
|
c.user = true;
|
|
210
|
-
Effects
|
|
208
|
+
Effects ? Effects.push(c) : queueMicrotask(() => updateComputation(c));
|
|
209
|
+
}
|
|
210
|
+
function createReaction(onInvalidate, options) {
|
|
211
|
+
let fn;
|
|
212
|
+
const c = createComputation(() => {
|
|
213
|
+
fn ? fn() : untrack(onInvalidate);
|
|
214
|
+
fn = undefined;
|
|
215
|
+
}, undefined, false, 0, options ),
|
|
216
|
+
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
217
|
+
if (s) c.suspense = s;
|
|
218
|
+
c.user = true;
|
|
219
|
+
return tracking => {
|
|
220
|
+
fn = tracking;
|
|
221
|
+
updateComputation(c);
|
|
222
|
+
};
|
|
211
223
|
}
|
|
212
224
|
function createMemo(fn, value, options) {
|
|
213
225
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -237,7 +249,7 @@ function createResource(source, fetcher, options) {
|
|
|
237
249
|
if (options.globalRefetch !== false) {
|
|
238
250
|
Resources || (Resources = new Set());
|
|
239
251
|
Resources.add(load);
|
|
240
|
-
onCleanup(() => Resources.delete(load));
|
|
252
|
+
Owner && onCleanup(() => Resources.delete(load));
|
|
241
253
|
}
|
|
242
254
|
const contexts = new Set(),
|
|
243
255
|
[s, set] = createSignal(options.initialValue),
|
|
@@ -348,7 +360,7 @@ function createResource(source, fetcher, options) {
|
|
|
348
360
|
}
|
|
349
361
|
let Resources;
|
|
350
362
|
function refetchResources(info) {
|
|
351
|
-
Resources && Resources.
|
|
363
|
+
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
352
364
|
}
|
|
353
365
|
function createDeferred(source, options) {
|
|
354
366
|
let t,
|
|
@@ -773,7 +785,7 @@ function runUpdates(fn, init) {
|
|
|
773
785
|
if (Effects) wait = true;else Effects = [];
|
|
774
786
|
ExecCount++;
|
|
775
787
|
try {
|
|
776
|
-
fn();
|
|
788
|
+
return fn();
|
|
777
789
|
} catch (err) {
|
|
778
790
|
handleError(err);
|
|
779
791
|
} finally {
|
|
@@ -1565,4 +1577,4 @@ if (globalThis) {
|
|
|
1565
1577
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1566
1578
|
}
|
|
1567
1579
|
|
|
1568
|
-
export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
1580
|
+
export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/dist/server.cjs
CHANGED
|
@@ -54,6 +54,11 @@ function createComputed(fn, value) {
|
|
|
54
54
|
}
|
|
55
55
|
const createRenderEffect = createComputed;
|
|
56
56
|
function createEffect(fn, value) {}
|
|
57
|
+
function createReaction(fn) {
|
|
58
|
+
return fn => {
|
|
59
|
+
fn();
|
|
60
|
+
};
|
|
61
|
+
}
|
|
57
62
|
function createMemo(fn, value) {
|
|
58
63
|
Owner = {
|
|
59
64
|
owner: Owner,
|
|
@@ -529,6 +534,7 @@ exports.createContext = createContext;
|
|
|
529
534
|
exports.createDeferred = createDeferred;
|
|
530
535
|
exports.createEffect = createEffect;
|
|
531
536
|
exports.createMemo = createMemo;
|
|
537
|
+
exports.createReaction = createReaction;
|
|
532
538
|
exports.createRenderEffect = createRenderEffect;
|
|
533
539
|
exports.createResource = createResource;
|
|
534
540
|
exports.createRoot = createRoot;
|
package/dist/server.js
CHANGED
|
@@ -50,6 +50,11 @@ function createComputed(fn, value) {
|
|
|
50
50
|
}
|
|
51
51
|
const createRenderEffect = createComputed;
|
|
52
52
|
function createEffect(fn, value) {}
|
|
53
|
+
function createReaction(fn) {
|
|
54
|
+
return fn => {
|
|
55
|
+
fn();
|
|
56
|
+
};
|
|
57
|
+
}
|
|
53
58
|
function createMemo(fn, value) {
|
|
54
59
|
Owner = {
|
|
55
60
|
owner: Owner,
|
|
@@ -506,4 +511,4 @@ function Suspense(props) {
|
|
|
506
511
|
return props.fallback;
|
|
507
512
|
}
|
|
508
513
|
|
|
509
|
-
export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
514
|
+
export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/dist/solid.cjs
CHANGED
|
@@ -168,14 +168,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
168
168
|
};
|
|
169
169
|
Owner = root;
|
|
170
170
|
Listener = null;
|
|
171
|
-
let result;
|
|
172
171
|
try {
|
|
173
|
-
runUpdates(() =>
|
|
172
|
+
return runUpdates(() => fn(() => cleanNode(root)), true);
|
|
174
173
|
} finally {
|
|
175
174
|
Listener = listener;
|
|
176
175
|
Owner = owner;
|
|
177
176
|
}
|
|
178
|
-
return result;
|
|
179
177
|
}
|
|
180
178
|
function createSignal(value, options) {
|
|
181
179
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -208,7 +206,21 @@ function createEffect(fn, value, options) {
|
|
|
208
206
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
209
207
|
if (s) c.suspense = s;
|
|
210
208
|
c.user = true;
|
|
211
|
-
Effects
|
|
209
|
+
Effects ? Effects.push(c) : queueMicrotask(() => updateComputation(c));
|
|
210
|
+
}
|
|
211
|
+
function createReaction(onInvalidate, options) {
|
|
212
|
+
let fn;
|
|
213
|
+
const c = createComputation(() => {
|
|
214
|
+
fn ? fn() : untrack(onInvalidate);
|
|
215
|
+
fn = undefined;
|
|
216
|
+
}, undefined, false, 0),
|
|
217
|
+
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
218
|
+
if (s) c.suspense = s;
|
|
219
|
+
c.user = true;
|
|
220
|
+
return tracking => {
|
|
221
|
+
fn = tracking;
|
|
222
|
+
updateComputation(c);
|
|
223
|
+
};
|
|
212
224
|
}
|
|
213
225
|
function createMemo(fn, value, options) {
|
|
214
226
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -238,7 +250,7 @@ function createResource(source, fetcher, options) {
|
|
|
238
250
|
if (options.globalRefetch !== false) {
|
|
239
251
|
Resources || (Resources = new Set());
|
|
240
252
|
Resources.add(load);
|
|
241
|
-
onCleanup(() => Resources.delete(load));
|
|
253
|
+
Owner && onCleanup(() => Resources.delete(load));
|
|
242
254
|
}
|
|
243
255
|
const contexts = new Set(),
|
|
244
256
|
[s, set] = createSignal(options.initialValue),
|
|
@@ -349,7 +361,7 @@ function createResource(source, fetcher, options) {
|
|
|
349
361
|
}
|
|
350
362
|
let Resources;
|
|
351
363
|
function refetchResources(info) {
|
|
352
|
-
Resources && Resources.
|
|
364
|
+
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
353
365
|
}
|
|
354
366
|
function createDeferred(source, options) {
|
|
355
367
|
let t,
|
|
@@ -720,7 +732,7 @@ function runUpdates(fn, init) {
|
|
|
720
732
|
if (Effects) wait = true;else Effects = [];
|
|
721
733
|
ExecCount++;
|
|
722
734
|
try {
|
|
723
|
-
fn();
|
|
735
|
+
return fn();
|
|
724
736
|
} catch (err) {
|
|
725
737
|
handleError(err);
|
|
726
738
|
} finally {
|
|
@@ -1497,6 +1509,7 @@ exports.createContext = createContext;
|
|
|
1497
1509
|
exports.createDeferred = createDeferred;
|
|
1498
1510
|
exports.createEffect = createEffect;
|
|
1499
1511
|
exports.createMemo = createMemo;
|
|
1512
|
+
exports.createReaction = createReaction;
|
|
1500
1513
|
exports.createRenderEffect = createRenderEffect;
|
|
1501
1514
|
exports.createResource = createResource;
|
|
1502
1515
|
exports.createRoot = createRoot;
|
package/dist/solid.js
CHANGED
|
@@ -164,14 +164,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
164
164
|
};
|
|
165
165
|
Owner = root;
|
|
166
166
|
Listener = null;
|
|
167
|
-
let result;
|
|
168
167
|
try {
|
|
169
|
-
runUpdates(() =>
|
|
168
|
+
return runUpdates(() => fn(() => cleanNode(root)), true);
|
|
170
169
|
} finally {
|
|
171
170
|
Listener = listener;
|
|
172
171
|
Owner = owner;
|
|
173
172
|
}
|
|
174
|
-
return result;
|
|
175
173
|
}
|
|
176
174
|
function createSignal(value, options) {
|
|
177
175
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -204,7 +202,21 @@ function createEffect(fn, value, options) {
|
|
|
204
202
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
205
203
|
if (s) c.suspense = s;
|
|
206
204
|
c.user = true;
|
|
207
|
-
Effects
|
|
205
|
+
Effects ? Effects.push(c) : queueMicrotask(() => updateComputation(c));
|
|
206
|
+
}
|
|
207
|
+
function createReaction(onInvalidate, options) {
|
|
208
|
+
let fn;
|
|
209
|
+
const c = createComputation(() => {
|
|
210
|
+
fn ? fn() : untrack(onInvalidate);
|
|
211
|
+
fn = undefined;
|
|
212
|
+
}, undefined, false, 0),
|
|
213
|
+
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
214
|
+
if (s) c.suspense = s;
|
|
215
|
+
c.user = true;
|
|
216
|
+
return tracking => {
|
|
217
|
+
fn = tracking;
|
|
218
|
+
updateComputation(c);
|
|
219
|
+
};
|
|
208
220
|
}
|
|
209
221
|
function createMemo(fn, value, options) {
|
|
210
222
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -234,7 +246,7 @@ function createResource(source, fetcher, options) {
|
|
|
234
246
|
if (options.globalRefetch !== false) {
|
|
235
247
|
Resources || (Resources = new Set());
|
|
236
248
|
Resources.add(load);
|
|
237
|
-
onCleanup(() => Resources.delete(load));
|
|
249
|
+
Owner && onCleanup(() => Resources.delete(load));
|
|
238
250
|
}
|
|
239
251
|
const contexts = new Set(),
|
|
240
252
|
[s, set] = createSignal(options.initialValue),
|
|
@@ -345,7 +357,7 @@ function createResource(source, fetcher, options) {
|
|
|
345
357
|
}
|
|
346
358
|
let Resources;
|
|
347
359
|
function refetchResources(info) {
|
|
348
|
-
Resources && Resources.
|
|
360
|
+
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
349
361
|
}
|
|
350
362
|
function createDeferred(source, options) {
|
|
351
363
|
let t,
|
|
@@ -716,7 +728,7 @@ function runUpdates(fn, init) {
|
|
|
716
728
|
if (Effects) wait = true;else Effects = [];
|
|
717
729
|
ExecCount++;
|
|
718
730
|
try {
|
|
719
|
-
fn();
|
|
731
|
+
return fn();
|
|
720
732
|
} catch (err) {
|
|
721
733
|
handleError(err);
|
|
722
734
|
} finally {
|
|
@@ -1473,4 +1485,4 @@ function Suspense(props) {
|
|
|
1473
1485
|
|
|
1474
1486
|
let DEV;
|
|
1475
1487
|
|
|
1476
|
-
export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
1488
|
+
export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "A declarative JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "1.3.0-rc.
|
|
4
|
+
"version": "1.3.0-rc.4",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -144,5 +144,5 @@
|
|
|
144
144
|
"compiler",
|
|
145
145
|
"performance"
|
|
146
146
|
],
|
|
147
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "25d84f333fb0b2fd6f9e055148e66665c1a7d813"
|
|
148
148
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, refetchResources, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $DEVCOMP, $PROXY } from "./reactive/signal";
|
|
1
|
+
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createReaction, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, refetchResources, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $DEVCOMP, $PROXY } from "./reactive/signal";
|
|
2
2
|
export type { Accessor, Setter, Resource, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, Context, ReturnTypes } from "./reactive/signal";
|
|
3
3
|
export * from "./reactive/observable";
|
|
4
4
|
export * from "./reactive/scheduler";
|
|
@@ -158,6 +158,20 @@ export declare function createRenderEffect<Next, Init = undefined>(..._: undefin
|
|
|
158
158
|
*/
|
|
159
159
|
export declare function createEffect<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions): void;
|
|
160
160
|
export declare function createEffect<Next, Init = undefined>(..._: undefined extends Init ? [fn: EffectFunction<Init | Next, Next>, value?: Init, options?: EffectOptions] : [fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions]): void;
|
|
161
|
+
/**
|
|
162
|
+
* Creates a reactive computation that runs after the render phase with flexible tracking
|
|
163
|
+
* ```typescript
|
|
164
|
+
* export function createReaction(
|
|
165
|
+
* onInvalidate: () => void,
|
|
166
|
+
* options?: { name?: string }
|
|
167
|
+
* ): (fn: () => void) => void;
|
|
168
|
+
* ```
|
|
169
|
+
* @param invalidated a function that is called when tracked function is invalidated.
|
|
170
|
+
* @param options allows to set a name in dev mode for debugging purposes
|
|
171
|
+
*
|
|
172
|
+
* @description https://www.solidjs.com/docs/latest/api#createreaction
|
|
173
|
+
*/
|
|
174
|
+
export declare function createReaction(onInvalidate: () => void, options?: EffectOptions): (tracking: () => void) => void;
|
|
161
175
|
interface Memo<Prev, Next = Prev> extends SignalState<Next>, Computation<Next> {
|
|
162
176
|
tOwned?: Computation<Prev | Next, Next>[];
|
|
163
177
|
}
|
|
@@ -171,7 +185,7 @@ export interface MemoOptions<T> extends EffectOptions {
|
|
|
171
185
|
* fn: (v: T) => T,
|
|
172
186
|
* value?: T,
|
|
173
187
|
* options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
|
|
174
|
-
* ): T;
|
|
188
|
+
* ): () => T;
|
|
175
189
|
* ```
|
|
176
190
|
* @param fn a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
|
|
177
191
|
* @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
|
|
@@ -236,7 +250,7 @@ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S,
|
|
|
236
250
|
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
237
251
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
238
252
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
239
|
-
export declare function refetchResources(info?: unknown):
|
|
253
|
+
export declare function refetchResources(info?: unknown): Promise<any[]>;
|
|
240
254
|
export interface DeferredOptions<T> {
|
|
241
255
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
242
256
|
name?: string;
|
|
@@ -357,7 +371,7 @@ export declare function onCleanup(fn: () => void): () => void;
|
|
|
357
371
|
export declare function onError(fn: (err: any) => void): void;
|
|
358
372
|
export declare function getListener(): Computation<any, any> | null;
|
|
359
373
|
export declare function getOwner(): Owner | null;
|
|
360
|
-
export declare function runWithOwner(o: Owner, fn: () =>
|
|
374
|
+
export declare function runWithOwner<T>(o: Owner, fn: () => T): T;
|
|
361
375
|
export declare function enableScheduling(scheduler?: typeof requestCallback): void;
|
|
362
376
|
/**
|
|
363
377
|
* ```typescript
|
package/types/server/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createRoot, createSignal, createComputed, createRenderEffect, createEffect, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, observable, from, $PROXY, $DEVCOMP, DEV, enableExternalSource } from "./reactive";
|
|
1
|
+
export { createRoot, createSignal, createComputed, createRenderEffect, createEffect, createReaction, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, observable, from, $PROXY, $DEVCOMP, DEV, enableExternalSource } from "./reactive";
|
|
2
2
|
export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource, enableScheduling, enableHydration, startTransition, useTransition, createUniqueId, lazy, sharedConfig } from "./rendering";
|
|
3
3
|
export type { Component, Resource } from "./rendering";
|
|
@@ -16,6 +16,7 @@ export declare function createSignal<T>(value: T, options?: {
|
|
|
16
16
|
export declare function createComputed<T>(fn: (v?: T) => T, value?: T): void;
|
|
17
17
|
export declare const createRenderEffect: typeof createComputed;
|
|
18
18
|
export declare function createEffect<T>(fn: (v?: T) => T, value?: T): void;
|
|
19
|
+
export declare function createReaction(fn: () => void): (fn: () => void) => void;
|
|
19
20
|
export declare function createMemo<T>(fn: (v?: T) => T, value?: T): () => T;
|
|
20
21
|
export declare function createDeferred<T>(source: () => T): () => T;
|
|
21
22
|
export declare function createSelector<T>(source: () => T, fn: (k: T, value: T) => boolean): (k: T) => boolean;
|