solid-ctrl-flow 1.0.52 → 1.0.54

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
@@ -127,15 +127,6 @@ export declare function createReactiveResource<R>(f: EffectFunction<R | undefine
127
127
  /** Built-in {@link ReactiveContext} which allows you to display different things in debug mode */
128
128
  export declare const debug: ReactiveContext<boolean>;
129
129
 
130
- /**
131
- * Defines a reactive property on an object
132
- * @param obj The object on which to define the property
133
- * @param k The key of the property that will be defined
134
- * @param param2 The {@link Signal} to use as the data store of the property
135
- * @returns The same thing passed as {@link obj}
136
- */
137
- export declare function defineSignalProperty<const T, K extends keyof T>(obj: T, k: K, [get, set]: Signal<T[K]>): T;
138
-
139
130
  /**
140
131
  * Eventually wraps its content into a template if a certain condition is met.
141
132
  * If you set {@link Standard.recycled} to `true`, the content will be memoized in the beginning and will be recycled even if the wrapper changes.
@@ -151,6 +142,13 @@ export declare function Enfold<T>(props: Unkeyed<T>): JSX.Element;
151
142
  /** Handy type alias */
152
143
  declare type Equals = MemoOptions<unknown>["equals"];
153
144
 
145
+ /**
146
+ * Creates a {@link Signal} that behaves like the input one, with the only difference that each call to the setter will trigger the effects even if the value didn't change.
147
+ * Can give reactivity to a fake {@link Signal}
148
+ * @param param0 The {@link Signal} to force
149
+ */
150
+ export declare function forceSignal<T>([get, set]: Signal<T>): Signal<T>;
151
+
154
152
  /** Parameters to pass to a keyed {@link Enfold} */
155
153
  declare type Keyed<T> = Standard<T> & {
156
154
  keyed: true;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, untrack, createEffect, on, createResource, splitProps, Show, onCleanup, For, Match, mergeProps, createRenderEffect, getListener } from "solid-js";
1
+ import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, untrack, createEffect, on, createResource, splitProps, Show, onCleanup, For, Match, mergeProps, createRenderEffect, createSignal, getListener } from "solid-js";
2
2
  import { createMutable } from "solid-js/store";
3
3
  const BASE_CTOR = Function;
4
4
  class ReactiveContext extends BASE_CTOR {
@@ -67,15 +67,6 @@ function runWithContext(ctx2, value, f) {
67
67
  function untrackCall(f, ...args) {
68
68
  return untrack(() => f.apply(this, args));
69
69
  }
70
- function defineSignalProperty(obj, k, [get, set]) {
71
- return Object.defineProperty(obj, k, {
72
- get,
73
- set: (x) => set(() => x),
74
- enumerable: true,
75
- writable: true,
76
- configurable: true
77
- });
78
- }
79
70
  function createReactiveResource(f) {
80
71
  var refetch;
81
72
  const memo = createMemo(f);
@@ -263,6 +254,16 @@ function toSignal(obj, k) {
263
254
  function unwrapSignal(f) {
264
255
  return [() => f()[0](), (x) => f()[1](x)];
265
256
  }
257
+ function forceSignal([get, set]) {
258
+ const [track, update] = createSignal(void 0, { equals: false });
259
+ return [
260
+ () => (track(), get()),
261
+ (x) => {
262
+ const out = set(x);
263
+ return update(), out;
264
+ }
265
+ ];
266
+ }
266
267
  function coalesceSignal([get, set], f) {
267
268
  return [getter, set];
268
269
  function getter() {
@@ -297,7 +298,7 @@ export {
297
298
  createExtractor,
298
299
  createReactiveResource,
299
300
  debug,
300
- defineSignalProperty,
301
+ forceSignal,
301
302
  memoProps,
302
303
  runWithContext,
303
304
  splitAndMemoProps,
package/dist/index.umd.js CHANGED
@@ -69,15 +69,6 @@
69
69
  function untrackCall(f, ...args) {
70
70
  return solidJs.untrack(() => f.apply(this, args));
71
71
  }
72
- function defineSignalProperty(obj, k, [get, set]) {
73
- return Object.defineProperty(obj, k, {
74
- get,
75
- set: (x) => set(() => x),
76
- enumerable: true,
77
- writable: true,
78
- configurable: true
79
- });
80
- }
81
72
  function createReactiveResource(f) {
82
73
  var refetch;
83
74
  const memo = solidJs.createMemo(f);
@@ -265,6 +256,16 @@
265
256
  function unwrapSignal(f) {
266
257
  return [() => f()[0](), (x) => f()[1](x)];
267
258
  }
259
+ function forceSignal([get, set]) {
260
+ const [track, update] = solidJs.createSignal(void 0, { equals: false });
261
+ return [
262
+ () => (track(), get()),
263
+ (x) => {
264
+ const out = set(x);
265
+ return update(), out;
266
+ }
267
+ ];
268
+ }
268
269
  function coalesceSignal([get, set], f) {
269
270
  return [getter, set];
270
271
  function getter() {
@@ -297,7 +298,7 @@
297
298
  exports2.createExtractor = createExtractor;
298
299
  exports2.createReactiveResource = createReactiveResource;
299
300
  exports2.debug = debug;
300
- exports2.defineSignalProperty = defineSignalProperty;
301
+ exports2.forceSignal = forceSignal;
301
302
  exports2.memoProps = memoProps;
302
303
  exports2.runWithContext = runWithContext;
303
304
  exports2.splitAndMemoProps = splitAndMemoProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "1.0.52",
3
+ "version": "1.0.54",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",
package/readMe.md CHANGED
@@ -179,6 +179,9 @@ Functions that create bindings between `Signal`s
179
179
  >
180
180
  > #### `unwrapSignal()`
181
181
  > A `Signal`-specific version of `unwrap()` that allows the destructuring of its result
182
+ >
183
+ > #### `forceSignal()`
184
+ > Creates a `Signal` that behaves like the input one, with the only difference that each call to the setter will trigger the effects even if the value didn't change
182
185
  >
183
186
  > #### `coalesceSignal()`
184
187
  > Creates a non nullable `Signal` from a nullable one
@@ -215,9 +218,6 @@ return <>
215
218
  ### `untrackCall()`
216
219
  Calls a function untracking what happens inside of it but not what gets passed as its argument
217
220
 
218
- ### `defineSignalProperty()`
219
- Defines a reactive property on an object
220
-
221
221
  ### `createReactiveResource()`
222
222
  Like `createResource()` but the provided function will be reactive
223
223