orpheus-bind
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -1,12 +0,12 @@ | ||
import { useState as F, useEffect as M, useCallback as _, useMemo as D } from "react"; | ||
import { BehaviorSubject as R } from "rxjs"; | ||
function h(e) { | ||
import { BehaviorSubject as F } from "rxjs"; | ||
import { useState as G, useEffect as D, useCallback as _ } from "react"; | ||
function p(e) { | ||
return typeof e == "function"; | ||
} | ||
function V(e) { | ||
return h(e == null ? void 0 : e.lift); | ||
function M(e) { | ||
return p(e == null ? void 0 : e.lift); | ||
} | ||
function Y(e) { | ||
function R(e) { | ||
return function(r) { | ||
if (V(r)) | ||
if (M(r)) | ||
return r.lift(function(t) { | ||
@@ -22,4 +22,4 @@ try { | ||
} | ||
var E = function(e, r) { | ||
return E = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) { | ||
var g = function(e, r) { | ||
return g = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) { | ||
t.__proto__ = n; | ||
@@ -29,8 +29,8 @@ } || function(t, n) { | ||
Object.prototype.hasOwnProperty.call(n, i) && (t[i] = n[i]); | ||
}, E(e, r); | ||
}, g(e, r); | ||
}; | ||
function x(e, r) { | ||
function w(e, r) { | ||
if (typeof r != "function" && r !== null) | ||
throw new TypeError("Class extends value " + String(r) + " is not a constructor or null"); | ||
E(e, r); | ||
g(e, r); | ||
function t() { | ||
@@ -57,8 +57,8 @@ this.constructor = e; | ||
return e; | ||
var n = t.call(e), i, o = [], u; | ||
var n = t.call(e), i, o = [], s; | ||
try { | ||
for (; (r === void 0 || r-- > 0) && !(i = n.next()).done; ) | ||
o.push(i.value); | ||
} catch (s) { | ||
u = { error: s }; | ||
} catch (u) { | ||
s = { error: u }; | ||
} finally { | ||
@@ -68,4 +68,4 @@ try { | ||
} finally { | ||
if (u) | ||
throw u.error; | ||
if (s) | ||
throw s.error; | ||
} | ||
@@ -75,3 +75,3 @@ } | ||
} | ||
function m(e, r, t) { | ||
function v(e, r, t) { | ||
if (t || arguments.length === 2) | ||
@@ -82,3 +82,3 @@ for (var n = 0, i = r.length, o; n < i; n++) | ||
} | ||
function k(e) { | ||
function V(e) { | ||
var r = function(n) { | ||
@@ -89,3 +89,3 @@ Error.call(n), n.stack = new Error().stack; | ||
} | ||
var S = k(function(e) { | ||
var S = V(function(e) { | ||
return function(t) { | ||
@@ -113,15 +113,15 @@ e(this), this.message = t ? t.length + ` errors occurred during unsubscription: | ||
this.closed = !0; | ||
var u = this._parentage; | ||
if (u) | ||
if (this._parentage = null, Array.isArray(u)) | ||
var s = this._parentage; | ||
if (s) | ||
if (this._parentage = null, Array.isArray(s)) | ||
try { | ||
for (var s = P(u), c = s.next(); !c.done; c = s.next()) { | ||
var f = c.value; | ||
f.remove(this); | ||
for (var u = P(s), c = u.next(); !c.done; c = u.next()) { | ||
var l = c.value; | ||
l.remove(this); | ||
} | ||
} catch (l) { | ||
r = { error: l }; | ||
} catch (a) { | ||
r = { error: a }; | ||
} finally { | ||
try { | ||
c && !c.done && (t = s.return) && t.call(s); | ||
c && !c.done && (t = u.return) && t.call(u); | ||
} finally { | ||
@@ -133,27 +133,27 @@ if (r) | ||
else | ||
u.remove(this); | ||
var a = this.initialTeardown; | ||
if (h(a)) | ||
s.remove(this); | ||
var f = this.initialTeardown; | ||
if (p(f)) | ||
try { | ||
a(); | ||
} catch (l) { | ||
o = l instanceof S ? l.errors : [l]; | ||
f(); | ||
} catch (a) { | ||
o = a instanceof S ? a.errors : [a]; | ||
} | ||
var d = this._finalizers; | ||
if (d) { | ||
var x = this._finalizers; | ||
if (x) { | ||
this._finalizers = null; | ||
try { | ||
for (var p = P(d), y = p.next(); !y.done; y = p.next()) { | ||
var C = y.value; | ||
for (var y = P(x), h = y.next(); !h.done; h = y.next()) { | ||
var C = h.value; | ||
try { | ||
O(C); | ||
} catch (l) { | ||
o = o ?? [], l instanceof S ? o = m(m([], b(o)), b(l.errors)) : o.push(l); | ||
} catch (a) { | ||
o = o ?? [], a instanceof S ? o = v(v([], b(o)), b(a.errors)) : o.push(a); | ||
} | ||
} | ||
} catch (l) { | ||
n = { error: l }; | ||
} catch (a) { | ||
n = { error: a }; | ||
} finally { | ||
try { | ||
y && !y.done && (i = p.return) && i.call(p); | ||
h && !h.done && (i = y.return) && i.call(y); | ||
} finally { | ||
@@ -199,9 +199,9 @@ if (n) | ||
T.EMPTY; | ||
function B(e) { | ||
return e instanceof T || e && "closed" in e && h(e.remove) && h(e.add) && h(e.unsubscribe); | ||
function Y(e) { | ||
return e instanceof T || e && "closed" in e && p(e.remove) && p(e.add) && p(e.unsubscribe); | ||
} | ||
function O(e) { | ||
h(e) ? e() : e.unsubscribe(); | ||
p(e) ? e() : e.unsubscribe(); | ||
} | ||
var G = { | ||
var k = { | ||
onUnhandledError: null, | ||
@@ -212,11 +212,11 @@ onStoppedNotification: null, | ||
useDeprecatedNextContext: !1 | ||
}, w = { | ||
}, E = { | ||
setTimeout: function(e, r) { | ||
for (var t = [], n = 2; n < arguments.length; n++) | ||
t[n - 2] = arguments[n]; | ||
var i = w.delegate; | ||
return i != null && i.setTimeout ? i.setTimeout.apply(i, m([e, r], b(t))) : setTimeout.apply(void 0, m([e, r], b(t))); | ||
var i = E.delegate; | ||
return i != null && i.setTimeout ? i.setTimeout.apply(i, v([e, r], b(t))) : setTimeout.apply(void 0, v([e, r], b(t))); | ||
}, | ||
clearTimeout: function(e) { | ||
var r = w.delegate; | ||
var r = E.delegate; | ||
return ((r == null ? void 0 : r.clearTimeout) || clearTimeout)(e); | ||
@@ -226,4 +226,4 @@ }, | ||
}; | ||
function H(e) { | ||
w.setTimeout(function() { | ||
function B(e) { | ||
E.setTimeout(function() { | ||
throw e; | ||
@@ -235,6 +235,6 @@ }); | ||
var j = function(e) { | ||
x(r, e); | ||
w(r, e); | ||
function r(t) { | ||
var n = e.call(this) || this; | ||
return n.isStopped = !1, t ? (n.destination = t, B(t) && t.add(n)) : n.destination = $, n; | ||
return n.isStopped = !1, t ? (n.destination = t, Y(t) && t.add(n)) : n.destination = $, n; | ||
} | ||
@@ -266,7 +266,7 @@ return r.create = function(t, n, i) { | ||
}, r; | ||
}(T), K = Function.prototype.bind; | ||
function g(e, r) { | ||
return K.call(e, r); | ||
}(T), H = Function.prototype.bind; | ||
function m(e, r) { | ||
return H.call(e, r); | ||
} | ||
var z = function() { | ||
var K = function() { | ||
function e(r) { | ||
@@ -281,3 +281,3 @@ this.partialObserver = r; | ||
} catch (n) { | ||
v(n); | ||
d(n); | ||
} | ||
@@ -290,6 +290,6 @@ }, e.prototype.error = function(r) { | ||
} catch (n) { | ||
v(n); | ||
d(n); | ||
} | ||
else | ||
v(r); | ||
d(r); | ||
}, e.prototype.complete = function() { | ||
@@ -301,11 +301,11 @@ var r = this.partialObserver; | ||
} catch (t) { | ||
v(t); | ||
d(t); | ||
} | ||
}, e; | ||
}(), I = function(e) { | ||
x(r, e); | ||
w(r, e); | ||
function r(t, n, i) { | ||
var o = e.call(this) || this, u; | ||
if (h(t) || !t) | ||
u = { | ||
var o = e.call(this) || this, s; | ||
if (p(t) || !t) | ||
s = { | ||
next: t ?? void 0, | ||
@@ -316,17 +316,17 @@ error: n ?? void 0, | ||
else { | ||
var s; | ||
o && G.useDeprecatedNextContext ? (s = Object.create(t), s.unsubscribe = function() { | ||
var u; | ||
o && k.useDeprecatedNextContext ? (u = Object.create(t), u.unsubscribe = function() { | ||
return o.unsubscribe(); | ||
}, u = { | ||
next: t.next && g(t.next, s), | ||
error: t.error && g(t.error, s), | ||
complete: t.complete && g(t.complete, s) | ||
}) : u = t; | ||
}, s = { | ||
next: t.next && m(t.next, u), | ||
error: t.error && m(t.error, u), | ||
complete: t.complete && m(t.complete, u) | ||
}) : s = t; | ||
} | ||
return o.destination = new z(u), o; | ||
return o.destination = new K(s), o; | ||
} | ||
return r; | ||
}(j); | ||
function v(e) { | ||
H(e); | ||
function d(e) { | ||
B(e); | ||
} | ||
@@ -349,16 +349,16 @@ function L(e) { | ||
var Q = function(e) { | ||
x(r, e); | ||
function r(t, n, i, o, u, s) { | ||
w(r, e); | ||
function r(t, n, i, o, s, u) { | ||
var c = e.call(this, t) || this; | ||
return c.onFinalize = u, c.shouldUnsubscribe = s, c._next = n ? function(f) { | ||
return c.onFinalize = s, c.shouldUnsubscribe = u, c._next = n ? function(l) { | ||
try { | ||
n(f); | ||
} catch (a) { | ||
t.error(a); | ||
n(l); | ||
} catch (f) { | ||
t.error(f); | ||
} | ||
} : e.prototype._next, c._error = o ? function(f) { | ||
} : e.prototype._next, c._error = o ? function(l) { | ||
try { | ||
o(f); | ||
} catch (a) { | ||
t.error(a); | ||
o(l); | ||
} catch (f) { | ||
t.error(f); | ||
} finally { | ||
@@ -370,4 +370,4 @@ this.unsubscribe(); | ||
i(); | ||
} catch (f) { | ||
t.error(f); | ||
} catch (l) { | ||
t.error(l); | ||
} finally { | ||
@@ -387,7 +387,7 @@ this.unsubscribe(); | ||
function W(e, r) { | ||
return r === void 0 && (r = q), e = e ?? X, Y(function(t, n) { | ||
return r === void 0 && (r = q), e = e ?? X, R(function(t, n) { | ||
var i, o = !0; | ||
t.subscribe(J(n, function(u) { | ||
var s = r(u); | ||
(o || !e(i, s)) && (o = !1, i = s, n.next(u)); | ||
t.subscribe(J(n, function(s) { | ||
var u = r(s); | ||
(o || !e(i, u)) && (o = !1, i = u, n.next(s)); | ||
})); | ||
@@ -399,22 +399,38 @@ }); | ||
} | ||
function tt(e, r = {}) { | ||
const { middleware: t } = r, n = new R(e); | ||
function i() { | ||
const [o, u] = F(n.getValue()); | ||
M(() => { | ||
const a = n.pipe(W()).subscribe(u); | ||
return () => a.unsubscribe(); | ||
function Z({ initialState: e, middleware: r }) { | ||
const t = new F(e); | ||
function n() { | ||
return t.getValue(); | ||
} | ||
function i(u) { | ||
return t.pipe(W()).subscribe(u); | ||
} | ||
function o(u) { | ||
const c = t.getValue(), l = typeof u == "function" ? u(c) : u, f = r ? r(c, l) : l; | ||
t.next(f); | ||
} | ||
function s() { | ||
t.next(e); | ||
} | ||
return { getState: n, subscribe: i, setState: o, resetState: s }; | ||
} | ||
function tt(e) { | ||
const r = Z(e); | ||
return function() { | ||
const [n, i] = G(r.getState()); | ||
D(() => { | ||
const u = r.subscribe(i); | ||
return () => u.unsubscribe(); | ||
}, []); | ||
const s = _((a) => { | ||
const d = n.getValue(), p = t ? t(d, a) : a; | ||
typeof p == "function" ? n.next(p(d)) : n.next(p); | ||
}, []), c = _(() => { | ||
n.next(e); | ||
const o = _((u) => { | ||
r.setState(u); | ||
}, []), s = _(() => { | ||
r.resetState(); | ||
}, []); | ||
return [D(() => o, [o]), s, c]; | ||
} | ||
return i; | ||
return [n, o, s]; | ||
}; | ||
} | ||
export { | ||
tt as createGlobalState | ||
Z as createGlobalState, | ||
tt as createUseGlobalState | ||
}; |
{ | ||
"name": "orpheus-bind", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"author": "JoaoPauloCMarra <joaopaulocmarra@gmail.com> (http://webnexus.com.br/)", | ||
@@ -14,3 +14,3 @@ "license": "MIT", | ||
"module": "./dist/orpheus-bind.umd.cjs", | ||
"types": "./dist/OrpheusBind.d.ts", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
@@ -17,0 +17,0 @@ ".": { |
Sorry, the diff of this file is not supported yet
24817
7
462