solid-ctrl-flow 6.1.0 → 6.1.2
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/index.d.ts +8 -0
- package/dist/index.mjs +14 -3
- package/dist/index.umd.js +13 -2
- package/package.json +1 -1
- package/readMe.md +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ export declare function Case(props: ParentProps<{
|
|
|
11
11
|
value: unknown;
|
|
12
12
|
}>): JSX;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Runs {@link f} and ensures that its reactive resources are cleaned up not only when the current {@link Owner} is disposed, but also when the provided one is
|
|
16
|
+
* @param outer The {@link Owner} for which to listen for its disposal
|
|
17
|
+
* @param f The function to run
|
|
18
|
+
* @return The same thing {@link f} returned
|
|
19
|
+
*/
|
|
20
|
+
export declare function disposeWithOwner<T>(outer: Owner, f: Accessor<T>): T;
|
|
21
|
+
|
|
14
22
|
/**
|
|
15
23
|
* Eventually wraps its content into a template if a certain condition is met.
|
|
16
24
|
* If you set {@link Standard.recycled} to `true`, the content will be memoized in the beginning and will be recycled even if the wrapper changes.
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import { untrack, createRoot,
|
|
1
|
+
import { untrack, getOwner, createRoot, runWithOwner, onCleanup, createMemo, Show, createContext, useContext, For, createRenderEffect, on, splitProps, createSignal, batch, createSelector, equalFn, Match } from "solid-js";
|
|
2
2
|
import { createComponent, memo, mergeProps, spread } from "solid-js/web";
|
|
3
3
|
function untrackCall(f, ...args) {
|
|
4
4
|
return untrack(() => f.apply(this, args));
|
|
5
5
|
}
|
|
6
|
+
function disposeWithOwner(outer, f) {
|
|
7
|
+
const inner = getOwner();
|
|
8
|
+
return createRoot((d) => {
|
|
9
|
+
runWithOwner(outer, () => onCleanup(d));
|
|
10
|
+
runWithOwner(inner, () => onCleanup(d));
|
|
11
|
+
return f();
|
|
12
|
+
});
|
|
13
|
+
}
|
|
6
14
|
function runWithContext(ctx2, value, f) {
|
|
7
15
|
return createRoot((d) => {
|
|
8
16
|
try {
|
|
9
|
-
|
|
17
|
+
const owner = getOwner();
|
|
18
|
+
owner.context = { ...owner.context, [ctx2.id]: value };
|
|
10
19
|
return f(value === void 0 ? ctx2.defaultValue : value);
|
|
11
20
|
} finally {
|
|
12
21
|
d();
|
|
@@ -180,12 +189,13 @@ function Source(props) {
|
|
|
180
189
|
sources
|
|
181
190
|
} = state;
|
|
182
191
|
const order = createMemo(() => props.order);
|
|
192
|
+
const owner = getOwner();
|
|
183
193
|
const info = {
|
|
184
194
|
get order() {
|
|
185
195
|
return order();
|
|
186
196
|
},
|
|
187
197
|
get children() {
|
|
188
|
-
return props.children;
|
|
198
|
+
return disposeWithOwner(owner, () => props.children);
|
|
189
199
|
}
|
|
190
200
|
};
|
|
191
201
|
const node = new OrderedLinkedListNode(info);
|
|
@@ -291,6 +301,7 @@ export {
|
|
|
291
301
|
OrderedLinkedListNode,
|
|
292
302
|
SameContext,
|
|
293
303
|
Spread,
|
|
304
|
+
disposeWithOwner,
|
|
294
305
|
memoProps,
|
|
295
306
|
runWithContext,
|
|
296
307
|
splitAndMemoProps,
|
package/dist/index.umd.js
CHANGED
|
@@ -5,10 +5,19 @@
|
|
|
5
5
|
function untrackCall(f, ...args) {
|
|
6
6
|
return solidJs.untrack(() => f.apply(this, args));
|
|
7
7
|
}
|
|
8
|
+
function disposeWithOwner(outer, f) {
|
|
9
|
+
const inner = solidJs.getOwner();
|
|
10
|
+
return solidJs.createRoot((d) => {
|
|
11
|
+
solidJs.runWithOwner(outer, () => solidJs.onCleanup(d));
|
|
12
|
+
solidJs.runWithOwner(inner, () => solidJs.onCleanup(d));
|
|
13
|
+
return f();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
8
16
|
function runWithContext(ctx2, value, f) {
|
|
9
17
|
return solidJs.createRoot((d) => {
|
|
10
18
|
try {
|
|
11
|
-
|
|
19
|
+
const owner = solidJs.getOwner();
|
|
20
|
+
owner.context = { ...owner.context, [ctx2.id]: value };
|
|
12
21
|
return f(value === void 0 ? ctx2.defaultValue : value);
|
|
13
22
|
} finally {
|
|
14
23
|
d();
|
|
@@ -182,12 +191,13 @@
|
|
|
182
191
|
sources
|
|
183
192
|
} = state;
|
|
184
193
|
const order = solidJs.createMemo(() => props.order);
|
|
194
|
+
const owner = solidJs.getOwner();
|
|
185
195
|
const info = {
|
|
186
196
|
get order() {
|
|
187
197
|
return order();
|
|
188
198
|
},
|
|
189
199
|
get children() {
|
|
190
|
-
return props.children;
|
|
200
|
+
return disposeWithOwner(owner, () => props.children);
|
|
191
201
|
}
|
|
192
202
|
};
|
|
193
203
|
const node = new OrderedLinkedListNode(info);
|
|
@@ -292,6 +302,7 @@
|
|
|
292
302
|
exports2.OrderedLinkedListNode = OrderedLinkedListNode;
|
|
293
303
|
exports2.SameContext = SameContext;
|
|
294
304
|
exports2.Spread = Spread;
|
|
305
|
+
exports2.disposeWithOwner = disposeWithOwner;
|
|
295
306
|
exports2.memoProps = memoProps;
|
|
296
307
|
exports2.runWithContext = runWithContext;
|
|
297
308
|
exports2.splitAndMemoProps = splitAndMemoProps;
|
package/package.json
CHANGED
package/readMe.md
CHANGED
|
@@ -235,5 +235,8 @@ Like `splitProps()` but passes the every part except the last one to [`memoProps
|
|
|
235
235
|
### `untrackCall()`
|
|
236
236
|
Calls a function untracking what happens inside of it but not what gets passed as its argument
|
|
237
237
|
|
|
238
|
+
### `disposeWithOwner()`
|
|
239
|
+
Calls a function in a way that makes it so that the reactive resources it creates are managed by 2 `Owner`s
|
|
240
|
+
|
|
238
241
|
### `runWithContext()`
|
|
239
242
|
Creates a context scope that persists for the duration of a function
|