Comparing version 0.13.0-rc.1 to 0.13.0-rc.2
@@ -12,2 +12,72 @@ 'use strict'; | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function step(key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _next(value) { | ||
step("next", value); | ||
} | ||
function _throw(err) { | ||
step("throw", err); | ||
} | ||
_next(); | ||
}); | ||
}; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
//@noflow | ||
@@ -196,7 +266,7 @@ | ||
}) { | ||
const { | ||
eventID, | ||
nextSeq, | ||
getType | ||
} = basicCommon(domainName, name); | ||
const _basicCommon = basicCommon(domainName, name), | ||
eventID = _basicCommon.eventID, | ||
nextSeq = _basicCommon.nextSeq, | ||
getType = _basicCommon.getType; | ||
const handlers = new Set(); | ||
@@ -223,4 +293,3 @@ if (!config.isPlain) handlers.add((payload | ||
let canDispatch = true; | ||
return { ...result, | ||
return _objectSpread({}, result, { | ||
raw() { | ||
@@ -235,7 +304,26 @@ return result; | ||
dispatcher(result); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
for (const handler of handlers) { | ||
handler(payload, getState()); | ||
} // action$.next(payload) | ||
try { | ||
for (var _iterator = handlers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
const handler = _step.value; | ||
handler(payload, getState()); | ||
} // action$.next(payload) | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
} | ||
@@ -246,3 +334,3 @@ | ||
}; | ||
}); | ||
} | ||
@@ -284,7 +372,8 @@ | ||
const handlers = new Set(); | ||
const { | ||
eventID, | ||
nextSeq, | ||
getType | ||
} = basicCommon(domainName, name); | ||
const _basicCommon = basicCommon(domainName, name), | ||
eventID = _basicCommon.eventID, | ||
nextSeq = _basicCommon.nextSeq, | ||
getType = _basicCommon.getType; | ||
handlers.add((payload, state) => action$.next(payload)); | ||
@@ -338,5 +427,24 @@ let using = getWarn({ | ||
dispatcher(result, dispatch, dispatchHook); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
for (const handler of handlers) { | ||
handler(params, getState()); | ||
try { | ||
for (var _iterator = handlers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
const handler = _step.value; | ||
handler(params, getState()); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
@@ -357,4 +465,3 @@ | ||
let canDispatch = true; | ||
return { ...result, | ||
return _objectSpread({}, result, { | ||
raw() { | ||
@@ -384,3 +491,3 @@ return result; | ||
}; | ||
}); | ||
}; | ||
@@ -569,4 +676,3 @@ | ||
function mergeEffectOpts(defaults, opts) { | ||
if (opts === undefined) return { ...defaults | ||
}; | ||
if (opts === undefined) return _objectSpread({}, defaults); | ||
@@ -577,4 +683,4 @@ if (!(typeof opts === 'object' && opts != null)) { | ||
const resultObj = { ...defaults | ||
}; | ||
const resultObj = _objectSpread({}, defaults); | ||
Object.keys(opts).map(key => [key, opts[key]]).forEach(optsReducer, resultObj); | ||
@@ -732,6 +838,4 @@ return resultObj; | ||
if (typeof action.send === 'function') { | ||
const { | ||
send, | ||
meta | ||
} = action; | ||
const send = action.send, | ||
meta = action.meta; | ||
@@ -748,5 +852,3 @@ if (handler) { | ||
} else { | ||
const { | ||
meta | ||
} = action; | ||
const meta = action.meta; | ||
@@ -945,8 +1047,3 @@ if (handler) { | ||
constructor(parts = []) { | ||
Object.defineProperty(this, "parts", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.parts = void 0; | ||
this.parts = parts; | ||
@@ -962,26 +1059,6 @@ } | ||
constructor() { | ||
Object.defineProperty(this, "anyMap", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: new WeakMap() | ||
}); | ||
Object.defineProperty(this, "dispatchMap", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: new WeakMap() | ||
}); | ||
Object.defineProperty(this, "eventsMap", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: new WeakMap() | ||
}); | ||
Object.defineProperty(this, "referenceMap", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: new WeakMap() | ||
}); | ||
this.anyMap = new WeakMap(); | ||
this.dispatchMap = new WeakMap(); | ||
this.eventsMap = new WeakMap(); | ||
this.referenceMap = new WeakMap(); | ||
} | ||
@@ -1025,5 +1102,24 @@ | ||
getFromAnyMap(scope, instance).clear(); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
for (const listeners of getFromEventsMap(scope, instance).values()) { | ||
listeners.clear(); | ||
try { | ||
for (var _iterator = getFromEventsMap(scope, instance).values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
const listeners = _step.value; | ||
listeners.clear(); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
@@ -1039,4 +1135,24 @@ } | ||
for (const value of getFromEventsMap(scope, instance).values()) { | ||
count += value.size; | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = getFromEventsMap(scope, instance).values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
const value = _step2.value; | ||
count += value.size; | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
@@ -1091,4 +1207,6 @@ | ||
invariant(!refs.has(eventName), 'circular reference'); | ||
var _arr = [...refs]; | ||
for (const instance of [...refs]) { | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
const instance = _arr[_i]; | ||
emitSync(scope, instance, eventName, eventData); | ||
@@ -1102,4 +1220,6 @@ } | ||
if (refs.size === 0) return; | ||
var _arr2 = [...refs]; | ||
for (const instance of [...refs]) { | ||
for (var _i2 = 0; _i2 < _arr2.length; _i2++) { | ||
const instance = _arr2[_i2]; | ||
instance(eventData, eventName); | ||
@@ -1118,7 +1238,9 @@ } | ||
for (const listener of listeners) { | ||
for (var _i3 = 0; _i3 < listeners.length; _i3++) { | ||
const listener = listeners[_i3]; | ||
listener(eventData, eventName); | ||
} | ||
for (const listener of anyListeners) { | ||
for (var _i4 = 0; _i4 < anyListeners.length; _i4++) { | ||
const listener = anyListeners[_i4]; | ||
listener(eventData, eventName); | ||
@@ -1129,39 +1251,74 @@ } | ||
} | ||
async function emit(scope, instance, eventName, eventData) { | ||
const listeners = getListeners(scope, instance, eventName); | ||
const anyListeners = getFromAnyMap(scope, instance); | ||
const staticListeners = [...listeners]; | ||
const staticAnyListeners = [...anyListeners]; | ||
await resolvedPromise; | ||
emitCallbacks(scope, eventName, eventData); | ||
return Promise.all([...staticListeners.map(async listener => { | ||
if (listeners.has(listener)) { | ||
return listener(eventData, eventName); | ||
} | ||
}), ...staticAnyListeners.map(async listener => { | ||
if (anyListeners.has(listener)) { | ||
return listener(eventData, eventName); | ||
} | ||
})]); | ||
function emit(_x, _x2, _x3, _x4) { | ||
return _emit.apply(this, arguments); | ||
} | ||
async function emitSerial(scope, instance, eventName, eventData) { | ||
const listeners = getListeners(scope, instance, eventName); | ||
const anyListeners = getFromAnyMap(scope, instance); | ||
const staticListeners = [...listeners]; | ||
const staticAnyListeners = [...anyListeners]; | ||
await resolvedPromise; | ||
for (const listener of staticListeners) { | ||
if (listeners.has(listener)) { | ||
await listener(eventData, eventName); | ||
function _emit() { | ||
_emit = _asyncToGenerator(function* (scope, instance, eventName, eventData) { | ||
const listeners = getListeners(scope, instance, eventName); | ||
const anyListeners = getFromAnyMap(scope, instance); | ||
const staticListeners = [...listeners]; | ||
const staticAnyListeners = [...anyListeners]; | ||
yield resolvedPromise; | ||
emitCallbacks(scope, eventName, eventData); | ||
return Promise.all([...staticListeners.map( | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref = _asyncToGenerator(function* (listener) { | ||
if (listeners.has(listener)) { | ||
return listener(eventData, eventName); | ||
} | ||
}); | ||
return function (_x9) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}()), ...staticAnyListeners.map( | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref2 = _asyncToGenerator(function* (listener) { | ||
if (anyListeners.has(listener)) { | ||
return listener(eventData, eventName); | ||
} | ||
}); | ||
return function (_x10) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}())]); | ||
}); | ||
return _emit.apply(this, arguments); | ||
} | ||
function emitSerial(_x5, _x6, _x7, _x8) { | ||
return _emitSerial.apply(this, arguments); | ||
} | ||
function _emitSerial() { | ||
_emitSerial = _asyncToGenerator(function* (scope, instance, eventName, eventData) { | ||
const listeners = getListeners(scope, instance, eventName); | ||
const anyListeners = getFromAnyMap(scope, instance); | ||
const staticListeners = [...listeners]; | ||
const staticAnyListeners = [...anyListeners]; | ||
yield resolvedPromise; | ||
for (var _i5 = 0; _i5 < staticListeners.length; _i5++) { | ||
const listener = staticListeners[_i5]; | ||
if (listeners.has(listener)) { | ||
yield listener(eventData, eventName); | ||
} | ||
} | ||
} | ||
for (const listener of staticAnyListeners) { | ||
if (anyListeners.has(listener)) { | ||
await listener(eventData, eventName); | ||
for (var _i6 = 0; _i6 < staticAnyListeners.length; _i6++) { | ||
const listener = staticAnyListeners[_i6]; | ||
if (anyListeners.has(listener)) { | ||
yield listener(eventData, eventName); | ||
} | ||
} | ||
} | ||
emitCallbacks(scope, eventName, eventData); | ||
emitCallbacks(scope, eventName, eventData); | ||
}); | ||
return _emitSerial.apply(this, arguments); | ||
} | ||
@@ -1174,8 +1331,3 @@ | ||
constructor() { | ||
Object.defineProperty(this, "id", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: ++id | ||
}); | ||
this.id = ++id; | ||
} | ||
@@ -1288,8 +1440,3 @@ | ||
constructor(defaultValue) { | ||
Object.defineProperty(this, "meta", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.meta = void 0; | ||
let defValue = defaultValue instanceof Atomic ? () => { | ||
@@ -1302,9 +1449,10 @@ const result = defaultValue.get(); | ||
} : () => defaultValue; | ||
const { | ||
get, | ||
set, | ||
off, | ||
active, | ||
emission | ||
} = createAtom(remote(defValue)); | ||
const _createAtom = createAtom(remote(defValue)), | ||
get = _createAtom.get, | ||
set = _createAtom.set, | ||
off = _createAtom.off, | ||
active = _createAtom.active, | ||
emission = _createAtom.emission; | ||
Object.defineProperty(this, 'meta', { | ||
@@ -1326,7 +1474,7 @@ value() { | ||
get() { | ||
const { | ||
active, | ||
defaultValue, | ||
get | ||
} = this.meta(); | ||
const _meta = this.meta(), | ||
active = _meta.active, | ||
defaultValue = _meta.defaultValue, | ||
get = _meta.get; | ||
invariant(active.get(), 'inactive atom'); | ||
@@ -1337,6 +1485,6 @@ return getReturn(defaultValue(), get); | ||
set(newValue) { | ||
const { | ||
active, | ||
set | ||
} = this.meta(); | ||
const _meta2 = this.meta(), | ||
active = _meta2.active, | ||
set = _meta2.set; | ||
invariant(active.get(), 'inactive atom'); | ||
@@ -1444,4 +1592,24 @@ set.dispatchSync(newValue); // emission.emitSync(set, newValue) | ||
next(val) { | ||
for (const result of transformer(val)) { | ||
set(result); | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
try { | ||
for (var _iterator3 = transformer(val)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
const result = _step3.value; | ||
set(result); | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return != null) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
} | ||
} | ||
@@ -1448,0 +1616,0 @@ }, |
@@ -6,2 +6,72 @@ import { sync } from 'most-subject'; | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function step(key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _next(value) { | ||
step("next", value); | ||
} | ||
function _throw(err) { | ||
step("throw", err); | ||
} | ||
_next(); | ||
}); | ||
}; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
//@noflow | ||
@@ -190,7 +260,7 @@ | ||
}) { | ||
const { | ||
eventID, | ||
nextSeq, | ||
getType | ||
} = basicCommon(domainName, name); | ||
const _basicCommon = basicCommon(domainName, name), | ||
eventID = _basicCommon.eventID, | ||
nextSeq = _basicCommon.nextSeq, | ||
getType = _basicCommon.getType; | ||
const handlers = new Set(); | ||
@@ -217,4 +287,3 @@ if (!config.isPlain) handlers.add((payload | ||
let canDispatch = true; | ||
return { ...result, | ||
return _objectSpread({}, result, { | ||
raw() { | ||
@@ -229,7 +298,26 @@ return result; | ||
dispatcher(result); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
for (const handler of handlers) { | ||
handler(payload, getState()); | ||
} // action$.next(payload) | ||
try { | ||
for (var _iterator = handlers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
const handler = _step.value; | ||
handler(payload, getState()); | ||
} // action$.next(payload) | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
} | ||
@@ -240,3 +328,3 @@ | ||
}; | ||
}); | ||
} | ||
@@ -278,7 +366,8 @@ | ||
const handlers = new Set(); | ||
const { | ||
eventID, | ||
nextSeq, | ||
getType | ||
} = basicCommon(domainName, name); | ||
const _basicCommon = basicCommon(domainName, name), | ||
eventID = _basicCommon.eventID, | ||
nextSeq = _basicCommon.nextSeq, | ||
getType = _basicCommon.getType; | ||
handlers.add((payload, state) => action$.next(payload)); | ||
@@ -332,5 +421,24 @@ let using = getWarn({ | ||
dispatcher(result, dispatch, dispatchHook); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
for (const handler of handlers) { | ||
handler(params, getState()); | ||
try { | ||
for (var _iterator = handlers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
const handler = _step.value; | ||
handler(params, getState()); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
@@ -351,4 +459,3 @@ | ||
let canDispatch = true; | ||
return { ...result, | ||
return _objectSpread({}, result, { | ||
raw() { | ||
@@ -378,3 +485,3 @@ return result; | ||
}; | ||
}); | ||
}; | ||
@@ -563,4 +670,3 @@ | ||
function mergeEffectOpts(defaults, opts) { | ||
if (opts === undefined) return { ...defaults | ||
}; | ||
if (opts === undefined) return _objectSpread({}, defaults); | ||
@@ -571,4 +677,4 @@ if (!(typeof opts === 'object' && opts != null)) { | ||
const resultObj = { ...defaults | ||
}; | ||
const resultObj = _objectSpread({}, defaults); | ||
Object.keys(opts).map(key => [key, opts[key]]).forEach(optsReducer, resultObj); | ||
@@ -726,6 +832,4 @@ return resultObj; | ||
if (typeof action.send === 'function') { | ||
const { | ||
send, | ||
meta | ||
} = action; | ||
const send = action.send, | ||
meta = action.meta; | ||
@@ -742,5 +846,3 @@ if (handler) { | ||
} else { | ||
const { | ||
meta | ||
} = action; | ||
const meta = action.meta; | ||
@@ -939,8 +1041,3 @@ if (handler) { | ||
constructor(parts = []) { | ||
Object.defineProperty(this, "parts", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.parts = void 0; | ||
this.parts = parts; | ||
@@ -956,26 +1053,6 @@ } | ||
constructor() { | ||
Object.defineProperty(this, "anyMap", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: new WeakMap() | ||
}); | ||
Object.defineProperty(this, "dispatchMap", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: new WeakMap() | ||
}); | ||
Object.defineProperty(this, "eventsMap", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: new WeakMap() | ||
}); | ||
Object.defineProperty(this, "referenceMap", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: new WeakMap() | ||
}); | ||
this.anyMap = new WeakMap(); | ||
this.dispatchMap = new WeakMap(); | ||
this.eventsMap = new WeakMap(); | ||
this.referenceMap = new WeakMap(); | ||
} | ||
@@ -1019,5 +1096,24 @@ | ||
getFromAnyMap(scope, instance).clear(); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
for (const listeners of getFromEventsMap(scope, instance).values()) { | ||
listeners.clear(); | ||
try { | ||
for (var _iterator = getFromEventsMap(scope, instance).values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
const listeners = _step.value; | ||
listeners.clear(); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
@@ -1033,4 +1129,24 @@ } | ||
for (const value of getFromEventsMap(scope, instance).values()) { | ||
count += value.size; | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = getFromEventsMap(scope, instance).values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
const value = _step2.value; | ||
count += value.size; | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
@@ -1085,4 +1201,6 @@ | ||
invariant(!refs.has(eventName), 'circular reference'); | ||
var _arr = [...refs]; | ||
for (const instance of [...refs]) { | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
const instance = _arr[_i]; | ||
emitSync(scope, instance, eventName, eventData); | ||
@@ -1096,4 +1214,6 @@ } | ||
if (refs.size === 0) return; | ||
var _arr2 = [...refs]; | ||
for (const instance of [...refs]) { | ||
for (var _i2 = 0; _i2 < _arr2.length; _i2++) { | ||
const instance = _arr2[_i2]; | ||
instance(eventData, eventName); | ||
@@ -1112,7 +1232,9 @@ } | ||
for (const listener of listeners) { | ||
for (var _i3 = 0; _i3 < listeners.length; _i3++) { | ||
const listener = listeners[_i3]; | ||
listener(eventData, eventName); | ||
} | ||
for (const listener of anyListeners) { | ||
for (var _i4 = 0; _i4 < anyListeners.length; _i4++) { | ||
const listener = anyListeners[_i4]; | ||
listener(eventData, eventName); | ||
@@ -1123,39 +1245,74 @@ } | ||
} | ||
async function emit(scope, instance, eventName, eventData) { | ||
const listeners = getListeners(scope, instance, eventName); | ||
const anyListeners = getFromAnyMap(scope, instance); | ||
const staticListeners = [...listeners]; | ||
const staticAnyListeners = [...anyListeners]; | ||
await resolvedPromise; | ||
emitCallbacks(scope, eventName, eventData); | ||
return Promise.all([...staticListeners.map(async listener => { | ||
if (listeners.has(listener)) { | ||
return listener(eventData, eventName); | ||
} | ||
}), ...staticAnyListeners.map(async listener => { | ||
if (anyListeners.has(listener)) { | ||
return listener(eventData, eventName); | ||
} | ||
})]); | ||
function emit(_x, _x2, _x3, _x4) { | ||
return _emit.apply(this, arguments); | ||
} | ||
async function emitSerial(scope, instance, eventName, eventData) { | ||
const listeners = getListeners(scope, instance, eventName); | ||
const anyListeners = getFromAnyMap(scope, instance); | ||
const staticListeners = [...listeners]; | ||
const staticAnyListeners = [...anyListeners]; | ||
await resolvedPromise; | ||
for (const listener of staticListeners) { | ||
if (listeners.has(listener)) { | ||
await listener(eventData, eventName); | ||
function _emit() { | ||
_emit = _asyncToGenerator(function* (scope, instance, eventName, eventData) { | ||
const listeners = getListeners(scope, instance, eventName); | ||
const anyListeners = getFromAnyMap(scope, instance); | ||
const staticListeners = [...listeners]; | ||
const staticAnyListeners = [...anyListeners]; | ||
yield resolvedPromise; | ||
emitCallbacks(scope, eventName, eventData); | ||
return Promise.all([...staticListeners.map( | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref = _asyncToGenerator(function* (listener) { | ||
if (listeners.has(listener)) { | ||
return listener(eventData, eventName); | ||
} | ||
}); | ||
return function (_x9) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}()), ...staticAnyListeners.map( | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref2 = _asyncToGenerator(function* (listener) { | ||
if (anyListeners.has(listener)) { | ||
return listener(eventData, eventName); | ||
} | ||
}); | ||
return function (_x10) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}())]); | ||
}); | ||
return _emit.apply(this, arguments); | ||
} | ||
function emitSerial(_x5, _x6, _x7, _x8) { | ||
return _emitSerial.apply(this, arguments); | ||
} | ||
function _emitSerial() { | ||
_emitSerial = _asyncToGenerator(function* (scope, instance, eventName, eventData) { | ||
const listeners = getListeners(scope, instance, eventName); | ||
const anyListeners = getFromAnyMap(scope, instance); | ||
const staticListeners = [...listeners]; | ||
const staticAnyListeners = [...anyListeners]; | ||
yield resolvedPromise; | ||
for (var _i5 = 0; _i5 < staticListeners.length; _i5++) { | ||
const listener = staticListeners[_i5]; | ||
if (listeners.has(listener)) { | ||
yield listener(eventData, eventName); | ||
} | ||
} | ||
} | ||
for (const listener of staticAnyListeners) { | ||
if (anyListeners.has(listener)) { | ||
await listener(eventData, eventName); | ||
for (var _i6 = 0; _i6 < staticAnyListeners.length; _i6++) { | ||
const listener = staticAnyListeners[_i6]; | ||
if (anyListeners.has(listener)) { | ||
yield listener(eventData, eventName); | ||
} | ||
} | ||
} | ||
emitCallbacks(scope, eventName, eventData); | ||
emitCallbacks(scope, eventName, eventData); | ||
}); | ||
return _emitSerial.apply(this, arguments); | ||
} | ||
@@ -1168,8 +1325,3 @@ | ||
constructor() { | ||
Object.defineProperty(this, "id", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: ++id | ||
}); | ||
this.id = ++id; | ||
} | ||
@@ -1282,8 +1434,3 @@ | ||
constructor(defaultValue) { | ||
Object.defineProperty(this, "meta", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.meta = void 0; | ||
let defValue = defaultValue instanceof Atomic ? () => { | ||
@@ -1296,9 +1443,10 @@ const result = defaultValue.get(); | ||
} : () => defaultValue; | ||
const { | ||
get, | ||
set, | ||
off, | ||
active, | ||
emission | ||
} = createAtom(remote(defValue)); | ||
const _createAtom = createAtom(remote(defValue)), | ||
get = _createAtom.get, | ||
set = _createAtom.set, | ||
off = _createAtom.off, | ||
active = _createAtom.active, | ||
emission = _createAtom.emission; | ||
Object.defineProperty(this, 'meta', { | ||
@@ -1320,7 +1468,7 @@ value() { | ||
get() { | ||
const { | ||
active, | ||
defaultValue, | ||
get | ||
} = this.meta(); | ||
const _meta = this.meta(), | ||
active = _meta.active, | ||
defaultValue = _meta.defaultValue, | ||
get = _meta.get; | ||
invariant(active.get(), 'inactive atom'); | ||
@@ -1331,6 +1479,6 @@ return getReturn(defaultValue(), get); | ||
set(newValue) { | ||
const { | ||
active, | ||
set | ||
} = this.meta(); | ||
const _meta2 = this.meta(), | ||
active = _meta2.active, | ||
set = _meta2.set; | ||
invariant(active.get(), 'inactive atom'); | ||
@@ -1438,4 +1586,24 @@ set.dispatchSync(newValue); // emission.emitSync(set, newValue) | ||
next(val) { | ||
for (const result of transformer(val)) { | ||
set(result); | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
try { | ||
for (var _iterator3 = transformer(val)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
const result = _step3.value; | ||
set(result); | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return != null) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
} | ||
} | ||
@@ -1442,0 +1610,0 @@ }, |
{ | ||
"name": "effector", | ||
"version": "0.13.0-rc.1", | ||
"version": "0.13.0-rc.2", | ||
"description": "Redux effects", | ||
@@ -5,0 +5,0 @@ "main": "effector.cjs.js", |
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
85709
2862