solid-ctrl-flow 5.0.0 → 5.1.0
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 +11 -0
- package/dist/index.mjs +7 -2
- package/dist/index.umd.js +6 -1
- package/package.json +1 -1
- package/readMe.md +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -151,6 +151,17 @@ export declare class OrderedLinkedListNode<T> extends OrderedLinkedList<T> {
|
|
|
151
151
|
remove(): void;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Adds the {@link f} event listener to the {@link k} event of the {@link obj} emitter and removes it when the current reactive context is disposed
|
|
156
|
+
* @param obj The emitter to which to add the event listener
|
|
157
|
+
* @param k The key of the event for which to add the listener
|
|
158
|
+
* @param f The function to call when the event is emitted
|
|
159
|
+
*/
|
|
160
|
+
export declare function registerEventListener<K, F>(obj: {
|
|
161
|
+
addEventListener(k: K, f: F): void;
|
|
162
|
+
removeEventListener(k: K, f: F): void;
|
|
163
|
+
}, k: K, f: F): void;
|
|
164
|
+
|
|
154
165
|
/**
|
|
155
166
|
* Executes {@link f} with the provided value for the specified {@link Context}.
|
|
156
167
|
* You can pass `undefined` to {@link value} in order to get back the default value for {@link ctx}.
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { untrack, createRoot, getOwner, createMemo, Show, createContext, useContext,
|
|
1
|
+
import { untrack, onCleanup, createRoot, getOwner, createMemo, Show, createContext, useContext, For, createRenderEffect, on, splitProps, createSignal, createSelector, equalFn, Match, runWithOwner } 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 registerEventListener(obj, k, f) {
|
|
7
|
+
obj.addEventListener(k, f);
|
|
8
|
+
onCleanup(() => obj.removeEventListener(k, f));
|
|
9
|
+
}
|
|
6
10
|
function runWithContext(ctx2, value, f) {
|
|
7
11
|
return createRoot((d) => {
|
|
8
12
|
try {
|
|
@@ -219,7 +223,7 @@ const memoProps = (obj, equals) => new Proxy(obj, new MemoPropsHandler(getOwner(
|
|
|
219
223
|
const splitAndMemoProps = (obj, ...keys) => {
|
|
220
224
|
const out = splitProps(obj, ...keys);
|
|
221
225
|
for (var i = 0; i < keys.length; i++)
|
|
222
|
-
out[i] = memoProps(out[i]
|
|
226
|
+
out[i] = memoProps(out[i]);
|
|
223
227
|
return out;
|
|
224
228
|
};
|
|
225
229
|
class MemoPropsHandler {
|
|
@@ -270,6 +274,7 @@ export {
|
|
|
270
274
|
SameContext,
|
|
271
275
|
Spread,
|
|
272
276
|
memoProps,
|
|
277
|
+
registerEventListener,
|
|
273
278
|
runWithContext,
|
|
274
279
|
splitAndMemoProps,
|
|
275
280
|
untrackCall,
|
package/dist/index.umd.js
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
function untrackCall(f, ...args) {
|
|
6
6
|
return solidJs.untrack(() => f.apply(this, args));
|
|
7
7
|
}
|
|
8
|
+
function registerEventListener(obj, k, f) {
|
|
9
|
+
obj.addEventListener(k, f);
|
|
10
|
+
solidJs.onCleanup(() => obj.removeEventListener(k, f));
|
|
11
|
+
}
|
|
8
12
|
function runWithContext(ctx2, value, f) {
|
|
9
13
|
return solidJs.createRoot((d) => {
|
|
10
14
|
try {
|
|
@@ -221,7 +225,7 @@
|
|
|
221
225
|
const splitAndMemoProps = (obj, ...keys) => {
|
|
222
226
|
const out = solidJs.splitProps(obj, ...keys);
|
|
223
227
|
for (var i = 0; i < keys.length; i++)
|
|
224
|
-
out[i] = memoProps(out[i]
|
|
228
|
+
out[i] = memoProps(out[i]);
|
|
225
229
|
return out;
|
|
226
230
|
};
|
|
227
231
|
class MemoPropsHandler {
|
|
@@ -271,6 +275,7 @@
|
|
|
271
275
|
exports2.SameContext = SameContext;
|
|
272
276
|
exports2.Spread = Spread;
|
|
273
277
|
exports2.memoProps = memoProps;
|
|
278
|
+
exports2.registerEventListener = registerEventListener;
|
|
274
279
|
exports2.runWithContext = runWithContext;
|
|
275
280
|
exports2.splitAndMemoProps = splitAndMemoProps;
|
|
276
281
|
exports2.untrackCall = untrackCall;
|
package/package.json
CHANGED
package/readMe.md
CHANGED
|
@@ -233,5 +233,8 @@ Like `splitProps()` but passes the every part except the last one to [`memoProps
|
|
|
233
233
|
### `untrackCall()`
|
|
234
234
|
Calls a function untracking what happens inside of it but not what gets passed as its argument
|
|
235
235
|
|
|
236
|
+
### `registerEventListener()`
|
|
237
|
+
Adds an event listener and registers its removal
|
|
238
|
+
|
|
236
239
|
### `runWithContext()`
|
|
237
240
|
Creates a context scope that persists for the duration of a function
|