solid-ctrl-flow 1.0.34 → 1.0.35
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 +4 -4
- package/dist/index.mjs +5 -5
- package/dist/index.umd.js +5 -5
- package/package.json +1 -1
- package/readMe.md +36 -37
package/dist/index.d.ts
CHANGED
|
@@ -16,14 +16,14 @@ declare const BASE_CTOR: new <T>() => Accessor<T>;
|
|
|
16
16
|
* - As soon as the function is done executing the two {@link Signal}s will have the same value
|
|
17
17
|
* - If {@link source} changes, {@link dest} wont be instantly updated
|
|
18
18
|
* - If the current owner gets disposed before {@link dest} is updated, it never will
|
|
19
|
-
* @param source The source of the binding
|
|
20
|
-
* @param dest The destination of the binding
|
|
19
|
+
* @param source The getter of source of the binding
|
|
20
|
+
* @param dest The setter of destination of the binding
|
|
21
21
|
* @param to Conversion function from {@link S} to {@link D}
|
|
22
22
|
* @returns A function that disposes the binding
|
|
23
23
|
*/
|
|
24
|
-
export declare function bind<S>(source:
|
|
24
|
+
export declare function bind<S>(source: Accessor<S>, dest: Setter<S>): () => void;
|
|
25
25
|
|
|
26
|
-
export declare function bind<S, D>(source:
|
|
26
|
+
export declare function bind<S, D>(source: Accessor<S>, dest: Setter<D>, to: Convert<S, D>): () => void;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Creates a two-way binding between two {@link Signal}s calling {@link bind} two times
|
package/dist/index.mjs
CHANGED
|
@@ -142,13 +142,13 @@ function Joint(props) {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
const IDENTITY = (x) => x;
|
|
145
|
-
function bind(
|
|
146
|
-
const d = createRoot((d2) => (createRenderEffect(on(
|
|
145
|
+
function bind(source, dest, to = IDENTITY) {
|
|
146
|
+
const d = createRoot((d2) => (createRenderEffect(on(source, (x) => dest((prev) => to(x, prev)))), d2));
|
|
147
147
|
return onCleanup(d), d;
|
|
148
148
|
}
|
|
149
|
-
function bindTwoWay(source, dest, to
|
|
150
|
-
const a = bind(source, dest, to);
|
|
151
|
-
const b = bind(dest, source, from);
|
|
149
|
+
function bindTwoWay(source, dest, to, from) {
|
|
150
|
+
const a = bind(source[0], dest[1], to);
|
|
151
|
+
const b = bind(dest[0], source[1], from);
|
|
152
152
|
return () => (a(), b());
|
|
153
153
|
}
|
|
154
154
|
function toSetter(get, set) {
|
package/dist/index.umd.js
CHANGED
|
@@ -144,13 +144,13 @@
|
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
const IDENTITY = (x) => x;
|
|
147
|
-
function bind(
|
|
148
|
-
const d = solidJs.createRoot((d2) => (solidJs.createRenderEffect(solidJs.on(
|
|
147
|
+
function bind(source, dest, to = IDENTITY) {
|
|
148
|
+
const d = solidJs.createRoot((d2) => (solidJs.createRenderEffect(solidJs.on(source, (x) => dest((prev) => to(x, prev)))), d2));
|
|
149
149
|
return solidJs.onCleanup(d), d;
|
|
150
150
|
}
|
|
151
|
-
function bindTwoWay(source, dest, to
|
|
152
|
-
const a = bind(source, dest, to);
|
|
153
|
-
const b = bind(dest, source, from);
|
|
151
|
+
function bindTwoWay(source, dest, to, from) {
|
|
152
|
+
const a = bind(source[0], dest[1], to);
|
|
153
|
+
const b = bind(dest[0], source[1], from);
|
|
154
154
|
return () => (a(), b());
|
|
155
155
|
}
|
|
156
156
|
function toSetter(get, set) {
|
package/package.json
CHANGED
package/readMe.md
CHANGED
|
@@ -34,20 +34,6 @@ return <>
|
|
|
34
34
|
</>
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
### `Debug`
|
|
38
|
-
Allows you to define ui section that are only visible in debug or NOT in debug
|
|
39
|
-
```tsx
|
|
40
|
-
const value = false;
|
|
41
|
-
return <>
|
|
42
|
-
<Debug value={value}>
|
|
43
|
-
{/* (A LOT OF NESTING...) */}
|
|
44
|
-
<Show when={Debug.isDebug()}>
|
|
45
|
-
THIS WOULD BE VISIBLE IF "value" HAD BEEN {true}
|
|
46
|
-
</Show>
|
|
47
|
-
</Debug>
|
|
48
|
-
</>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
37
|
### `createExtractor()`
|
|
52
38
|
Creates a context for components that may need to be out of their parent in certain conditions.
|
|
53
39
|
If you have this component
|
|
@@ -122,6 +108,29 @@ Notice that you can use a `Source` component without adding it to the DOM:
|
|
|
122
108
|
return <>Something else</>
|
|
123
109
|
```
|
|
124
110
|
|
|
111
|
+
## Utility
|
|
112
|
+
|
|
113
|
+
### Bindings
|
|
114
|
+
Functions that create bindings between `Signal`s
|
|
115
|
+
|
|
116
|
+
> #### `bind()`
|
|
117
|
+
> Creates a one-way binding between two `Signal`s
|
|
118
|
+
>
|
|
119
|
+
> #### `bindTwoWay()`
|
|
120
|
+
> Creates a two-way binding between two `Signal`s
|
|
121
|
+
>
|
|
122
|
+
> #### `toSetter()`
|
|
123
|
+
> Creates a full-fledged solid `Setter` from a normal one
|
|
124
|
+
>
|
|
125
|
+
> #### `toSignal()`
|
|
126
|
+
> Creates a `Signal` from a property of an object
|
|
127
|
+
>
|
|
128
|
+
> #### `coalesceSignal()`
|
|
129
|
+
> Creates a non nullable `Signal` from a nullable one
|
|
130
|
+
>
|
|
131
|
+
> #### `unwrapSignal()`
|
|
132
|
+
> Calls an `Accessor` to a `Signal` maintaining its reactivity
|
|
133
|
+
|
|
125
134
|
### `ReactiveContext.create()`
|
|
126
135
|
Method that creates a reactive version of a solid `Context` with some additional built-in functionalities
|
|
127
136
|
```ts
|
|
@@ -131,29 +140,19 @@ const valueAccessorForTheCurrentOwner = ctx.read;
|
|
|
131
140
|
const value = ctx();
|
|
132
141
|
```
|
|
133
142
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
Creates a `Signal` from a property of an object
|
|
148
|
-
|
|
149
|
-
### `coalesceSignal()`
|
|
150
|
-
Creates a non nullable `Signal` from a nullable one
|
|
151
|
-
|
|
152
|
-
### `unwrapSignal()`
|
|
153
|
-
Calls an `Accessor` to a `Signal` maintaining its reactivity
|
|
154
|
-
|
|
155
|
-
## Utility functions
|
|
156
|
-
Utility functions needed for the components above
|
|
143
|
+
### `debug()`
|
|
144
|
+
Allows you to define ui section that are only visible in debug or NOT in debug
|
|
145
|
+
```tsx
|
|
146
|
+
const value = false;
|
|
147
|
+
return <>
|
|
148
|
+
<debug.Provider value={value}>
|
|
149
|
+
{/* (A LOT OF NESTING...) */}
|
|
150
|
+
<Show when={debug()}>
|
|
151
|
+
THIS WOULD BE VISIBLE IF "value" HAD BEEN {true}
|
|
152
|
+
</Show>
|
|
153
|
+
</debug.Provider>
|
|
154
|
+
</>
|
|
155
|
+
```
|
|
157
156
|
|
|
158
157
|
### `untrackCall()`
|
|
159
158
|
Calls a function untracking what happens inside of it but not what gets passed as its argument
|