solid-ctrl-flow 1.0.43 → 1.0.44

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, Match, mergeProps, splitProps, createEffect, on, createResource, untrack, Show, onCleanup, For, mapArray, createSignal, onMount, createRenderEffect } from "solid-js";
1
+ import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, Match, mergeProps, splitProps, createEffect, on, createResource, untrack, Show, onCleanup, For, mapArray, createSignal, onMount, createRenderEffect, 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 {
@@ -246,12 +246,23 @@ function toSignal(obj, k) {
246
246
  const get = () => obj()[k()];
247
247
  return [get, toSetter(get, (v) => obj()[k()] = v)];
248
248
  }
249
- function coalesceSignal([get, set], f) {
250
- return [() => get() ?? set(f), set];
251
- }
252
249
  function unwrapSignal(f) {
253
250
  return [() => f()[0](), (x) => f()[1](x)];
254
251
  }
252
+ function coalesceSignal([get, set], f) {
253
+ return [getter, set];
254
+ function getter() {
255
+ const out = get();
256
+ if (out != null)
257
+ return out;
258
+ const listener = getListener(), { state } = listener;
259
+ try {
260
+ return set(f);
261
+ } finally {
262
+ listener.state = state;
263
+ }
264
+ }
265
+ }
255
266
  const debug = ReactiveContext.create(false, "debug-scope");
256
267
  export {
257
268
  Case,
package/dist/index.umd.js CHANGED
@@ -248,12 +248,23 @@
248
248
  const get = () => obj()[k()];
249
249
  return [get, toSetter(get, (v) => obj()[k()] = v)];
250
250
  }
251
- function coalesceSignal([get, set], f) {
252
- return [() => get() ?? set(f), set];
253
- }
254
251
  function unwrapSignal(f) {
255
252
  return [() => f()[0](), (x) => f()[1](x)];
256
253
  }
254
+ function coalesceSignal([get, set], f) {
255
+ return [getter, set];
256
+ function getter() {
257
+ const out = get();
258
+ if (out != null)
259
+ return out;
260
+ const listener = solidJs.getListener(), { state } = listener;
261
+ try {
262
+ return set(f);
263
+ } finally {
264
+ listener.state = state;
265
+ }
266
+ }
267
+ }
257
268
  const debug = ReactiveContext.create(false, "debug-scope");
258
269
  exports2.Case = Case;
259
270
  exports2.Enfold = Enfold;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",
package/readMe.md CHANGED
@@ -180,11 +180,11 @@ Functions that create bindings between `Signal`s
180
180
  > #### `toSignal()`
181
181
  > Creates a `Signal` from a property of an object
182
182
  >
183
- > #### `coalesceSignal()`
184
- > Creates a non nullable `Signal` from a nullable one
185
- >
186
183
  > #### `unwrapSignal()`
187
184
  > A `Signal`-specific version of `unwrap()` that allows the destructuring of its result
185
+ >
186
+ > #### `coalesceSignal()`
187
+ > Creates a non nullable `Signal` from a nullable one
188
188
 
189
189
  ### `ReactiveContext.create()`
190
190
  Method that creates a reactive version of a solid `Context` with some additional built-in functionalities