solid-ctrl-flow 1.0.58 → 1.0.59
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 +6 -7
- package/dist/index.mjs +8 -9
- package/dist/index.umd.js +8 -9
- package/package.json +1 -1
- package/readMe.md +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ export declare class Atom<T> {
|
|
|
19
19
|
* @param f Function that creates a new value based on the current one
|
|
20
20
|
*/
|
|
21
21
|
update<V extends T>(f: (prev: T) => V): V;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new {@link Atom} that applies a conversion to the current one
|
|
24
|
+
* @param to Conversion function from {@link S} to {@link D}
|
|
25
|
+
* @param from Conversion function from {@link D} to {@link S}
|
|
26
|
+
*/
|
|
27
|
+
convert<R>(to: (x: T) => R, from: (x: R) => T): Atom<R>;
|
|
22
28
|
/**
|
|
23
29
|
* Creates an {@link Atom} that forwards an {@link Accessor} to another {@link Atom}
|
|
24
30
|
* @param f The reactive {@link Accessor} to the {@link Atom} to forward
|
|
@@ -29,13 +35,6 @@ export declare class Atom<T> {
|
|
|
29
35
|
* @param param0 The {@link Signal} to forward
|
|
30
36
|
*/
|
|
31
37
|
static from<T>([get, set]: Signal<T>): Atom<T>;
|
|
32
|
-
/**
|
|
33
|
-
* Creates a new {@link Atom} that applies a conversion to another {@link Atom}
|
|
34
|
-
* @param atom The {@link Atom} to which to apply the conversion
|
|
35
|
-
* @param to Conversion function from {@link S} to {@link D}
|
|
36
|
-
* @param from Conversion function from {@link D} to {@link S}
|
|
37
|
-
*/
|
|
38
|
-
static convert<S, D>(atom: Atom<S>, to: (x: S) => D, from: (x: D) => S): Atom<D>;
|
|
39
38
|
/**
|
|
40
39
|
* Creates a bindable data source.
|
|
41
40
|
* If {@link bind} returns an {@link Atom} it gets wrapped, otherwise it creates a {@link Signal} using {@link f} and uses it to store the value until {@link bind}'s value changes
|
package/dist/index.mjs
CHANGED
|
@@ -243,6 +243,14 @@ class Atom {
|
|
|
243
243
|
update(f) {
|
|
244
244
|
return this.value = f(untrack(this.get));
|
|
245
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Creates a new {@link Atom} that applies a conversion to the current one
|
|
248
|
+
* @param to Conversion function from {@link S} to {@link D}
|
|
249
|
+
* @param from Conversion function from {@link D} to {@link S}
|
|
250
|
+
*/
|
|
251
|
+
convert(to, from) {
|
|
252
|
+
return new Atom(() => to(this.value), (x) => this.value = from(x));
|
|
253
|
+
}
|
|
246
254
|
/**
|
|
247
255
|
* Creates an {@link Atom} that forwards an {@link Accessor} to another {@link Atom}
|
|
248
256
|
* @param f The reactive {@link Accessor} to the {@link Atom} to forward
|
|
@@ -257,15 +265,6 @@ class Atom {
|
|
|
257
265
|
static from([get, set]) {
|
|
258
266
|
return new this(get, (v) => set(() => v));
|
|
259
267
|
}
|
|
260
|
-
/**
|
|
261
|
-
* Creates a new {@link Atom} that applies a conversion to another {@link Atom}
|
|
262
|
-
* @param atom The {@link Atom} to which to apply the conversion
|
|
263
|
-
* @param to Conversion function from {@link S} to {@link D}
|
|
264
|
-
* @param from Conversion function from {@link D} to {@link S}
|
|
265
|
-
*/
|
|
266
|
-
static convert(atom, to, from) {
|
|
267
|
-
return new this(() => to(atom.value), (x) => atom.value = from(x));
|
|
268
|
-
}
|
|
269
268
|
static source(bind, f = createSignal) {
|
|
270
269
|
return this.unwrap(createMemo(on(bind, (x) => x ?? Atom.from(f()))));
|
|
271
270
|
}
|
package/dist/index.umd.js
CHANGED
|
@@ -245,6 +245,14 @@
|
|
|
245
245
|
update(f) {
|
|
246
246
|
return this.value = f(solidJs.untrack(this.get));
|
|
247
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* Creates a new {@link Atom} that applies a conversion to the current one
|
|
250
|
+
* @param to Conversion function from {@link S} to {@link D}
|
|
251
|
+
* @param from Conversion function from {@link D} to {@link S}
|
|
252
|
+
*/
|
|
253
|
+
convert(to, from) {
|
|
254
|
+
return new Atom(() => to(this.value), (x) => this.value = from(x));
|
|
255
|
+
}
|
|
248
256
|
/**
|
|
249
257
|
* Creates an {@link Atom} that forwards an {@link Accessor} to another {@link Atom}
|
|
250
258
|
* @param f The reactive {@link Accessor} to the {@link Atom} to forward
|
|
@@ -259,15 +267,6 @@
|
|
|
259
267
|
static from([get, set]) {
|
|
260
268
|
return new this(get, (v) => set(() => v));
|
|
261
269
|
}
|
|
262
|
-
/**
|
|
263
|
-
* Creates a new {@link Atom} that applies a conversion to another {@link Atom}
|
|
264
|
-
* @param atom The {@link Atom} to which to apply the conversion
|
|
265
|
-
* @param to Conversion function from {@link S} to {@link D}
|
|
266
|
-
* @param from Conversion function from {@link D} to {@link S}
|
|
267
|
-
*/
|
|
268
|
-
static convert(atom, to, from) {
|
|
269
|
-
return new this(() => to(atom.value), (x) => atom.value = from(x));
|
|
270
|
-
}
|
|
271
270
|
static source(bind, f = solidJs.createSignal) {
|
|
272
271
|
return this.unwrap(solidJs.createMemo(solidJs.on(bind, (x) => x ?? Atom.from(f()))));
|
|
273
272
|
}
|
package/package.json
CHANGED
package/readMe.md
CHANGED
|
@@ -171,14 +171,14 @@ Customizable and simplified wrappers for reactive states
|
|
|
171
171
|
> #### `Atom.update()`
|
|
172
172
|
> Like the `Setter` overload of a `Signal` that takes a function with the previous value
|
|
173
173
|
>
|
|
174
|
+
> #### `Atom.convert()`
|
|
175
|
+
> Creates a new `Atom` that applies a conversion to the current one
|
|
176
|
+
>
|
|
174
177
|
> #### `Atom.unwrap()`
|
|
175
178
|
> An `Atom`-specific (optimized) version of `unwrap()` that allows the destructuring of its result
|
|
176
179
|
>
|
|
177
180
|
> #### `Atom.from()`
|
|
178
181
|
> Creates an `Atom` from a `Signal`
|
|
179
|
-
>
|
|
180
|
-
> #### `Atom.convert()`
|
|
181
|
-
> Creates a new `Atom` that applies a conversion to another `Atom`
|
|
182
182
|
>
|
|
183
183
|
> #### `Atom.source()`
|
|
184
184
|
> Similiar to `Atom.unwrap()`, but if the `Accessor` doesn't return anything it automatically creates an internal `Signal` in which to store the value
|