Comparing version 0.5.11 to 0.5.12
@@ -40,2 +40,3 @@ import { FC } from 'react'; | ||
declare function ready<T = void>(init: T): Signal<T>; | ||
declare function ready<T>(init: T, to: T): Signal<void>; | ||
declare function wrap<T, K, P>(target: Signal<T, K>, set: () => T, get: (data: K) => P): Signal<void, P>; | ||
@@ -42,0 +43,0 @@ declare function wrap<T, K, P, M = T>(target: Signal<T, K>, set: (data: M) => T, get: (data: K) => P): Signal<M, P>; |
@@ -80,8 +80,14 @@ "use strict"; | ||
exports.signal = signal; | ||
function ready(init) { | ||
function ready(init, to) { | ||
let resolved = false; | ||
let resolve; | ||
const [get, set] = reactive_box_1.box([init]); | ||
const fn = function (data) { | ||
set([data]); | ||
resolve(data); | ||
if (!resolved) { | ||
resolved = true; | ||
if (to) | ||
data = to; | ||
set([data]); | ||
resolve(data); | ||
} | ||
}; | ||
@@ -88,0 +94,0 @@ def_format(fn, () => get()[0], fn, 1); |
{ | ||
"name": "realar", | ||
"version": "0.5.11", | ||
"version": "0.5.12", | ||
"description": "React state manager", | ||
@@ -88,3 +88,3 @@ "repository": { | ||
}, | ||
"gitHead": "c6d8c311f3fbe5a70fff4711cc5df471d624b53b" | ||
"gitHead": "315b346dcdb3868e0de928713d2a78781174002e" | ||
} |
@@ -430,3 +430,3 @@ # Realar | ||
_Documentation not ready yet for `effect`, `loop`, `pool`, `stoppable`, `initial`, `mock`, `unmock`, `free`, `transaction`, `untrack`, `isolate`, `wrap`, `ready` functions. It's coming soon._ | ||
_Documentation not ready yet for `effect`, `loop`, `pool`, `stoppable`, `initial`, `mock`, `unmock`, `free`, `transaction`, `untrack`, `isolate`, `wrap`, `ready`, `once` functions. It's coming soon._ | ||
@@ -433,0 +433,0 @@ ### Demos |
@@ -151,3 +151,5 @@ import React, { Context, FC } from 'react'; | ||
function ready<T = void>(init: T): Signal<T>; | ||
function ready(init?: any) { | ||
function ready<T>(init: T, to: T): Signal<void>; | ||
function ready(init?: any, to?: any) { | ||
let resolved = false; | ||
let resolve: any; | ||
@@ -157,4 +159,8 @@ const [get, set] = box([init]); | ||
const fn = function (data: any) { | ||
set([data]); | ||
resolve(data); | ||
if (!resolved) { | ||
resolved = true; | ||
if (to) data = to; | ||
set([data]); | ||
resolve(data); | ||
} | ||
}; | ||
@@ -161,0 +167,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65471
1109