webdetta 0.1.228 → 0.1.229
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/package.json
CHANGED
|
@@ -123,4 +123,13 @@ export const createIf = () => {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
return node;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const createDynamic = (deps, func) => {
|
|
129
|
+
const content = r.val();
|
|
130
|
+
r.effect(() => {
|
|
131
|
+
const arg = deps();
|
|
132
|
+
r.effect(() => content(func(arg)), { track: false })
|
|
133
|
+
});
|
|
134
|
+
return createSlot(content);
|
|
126
135
|
}
|
|
@@ -4,7 +4,7 @@ import { unwrapFn } from '../common/utils.js';
|
|
|
4
4
|
import { Context } from '../context/sync.js';
|
|
5
5
|
import { cached } from '../execution/index.js';
|
|
6
6
|
import { Operator, toString } from './base.js';
|
|
7
|
-
import { createIf, createList, createSlot } from './dynamic.js';
|
|
7
|
+
import { createIf, createList, createSlot, createDynamic } from './dynamic.js';
|
|
8
8
|
|
|
9
9
|
const api = {};
|
|
10
10
|
|
|
@@ -22,9 +22,9 @@ api.append = (node, ...args) => Element.append(node, args);
|
|
|
22
22
|
api.remove = Element.remove;
|
|
23
23
|
|
|
24
24
|
api.if = (cond, ...args) => createIf().elif(cond, args);
|
|
25
|
-
|
|
26
25
|
api.list = createList;
|
|
27
26
|
api.slot = createSlot;
|
|
27
|
+
api.dynamic = createDynamic;
|
|
28
28
|
|
|
29
29
|
api.attr = Operator((node, names, args) => {
|
|
30
30
|
const value = toString(...args);
|