solid-ctrl-flow 1.0.18 → 1.0.19

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 CHANGED
@@ -77,24 +77,33 @@ export declare function createExtractor(name?: string): {
77
77
 
78
78
  /**
79
79
  * Creates a context with a reactive value.
80
- * It returns the provider directly
80
+ * Returns a provider with additional fields:
81
+ * - The `read` getter, which returns an {@link Accessor} to the value
82
+ * - The `runWith()` method, which executes {@link runWithContext} on the option
81
83
  * @param init Initial value for the context
82
84
  * @param def Default value to set when calling the provider without one
83
85
  * @param name Name to give to the context
84
86
  */
85
- export declare function createOption<T>(init: T, def?: T, name?: string): ((props: {
86
- value?: T;
87
- children: JSX.Element;
88
- }) => JSX.Element) & {
87
+ export declare function createOption<T>(init: T, def?: T, name?: string): {
88
+ (props: {
89
+ value?: T;
90
+ children: JSX.Element;
91
+ }): JSX.Element;
92
+ /** Executes {@link runWithContext} on the provided option */
93
+ runWith<V extends T, R>(x: V, f: (x: V) => R): R;
94
+ } & {
89
95
  /** Returns the {@link Accessor} for the value in the current context */
90
96
  read: Accessor<T>;
91
97
  };
92
98
 
93
99
  /** Creates a scope for the value of {@link Debug.read}, which allows you to display different things in debug mode */
94
- export declare const Debug: ((props: {
95
- value?: boolean | undefined;
96
- children: JSX.Element;
97
- }) => JSX.Element) & {
100
+ export declare const Debug: {
101
+ (props: {
102
+ value?: boolean | undefined;
103
+ children: JSX.Element;
104
+ }): JSX.Element;
105
+ runWith<V extends boolean, R>(x: V, f: (x: V) => R): R;
106
+ } & {
98
107
  read: Accessor<boolean>;
99
108
  };
100
109
 
package/dist/index.mjs CHANGED
@@ -31,6 +31,7 @@ function createOption(init, def = init, name) {
31
31
  Object.defineProperty(provider, prop, {
32
32
  get: () => useContext(ctx2)
33
33
  });
34
+ provider.runWith = (x, f) => runWithContext(ctx2, () => x, () => f(x));
34
35
  return provider;
35
36
  }
36
37
  function runWithContext(ctx2, value, f) {
package/dist/index.umd.js CHANGED
@@ -33,6 +33,7 @@
33
33
  Object.defineProperty(provider, prop, {
34
34
  get: () => solidJs.useContext(ctx2)
35
35
  });
36
+ provider.runWith = (x, f) => runWithContext(ctx2, () => x, () => f(x));
36
37
  return provider;
37
38
  }
38
39
  function runWithContext(ctx2, value, f) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",