@remote-ui/async-subscription
Advanced tools
Comparing version 2.1.6 to 2.1.7
@@ -41,125 +41,2 @@ 'use strict'; | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); | ||
if (_i == null) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _s, _e; | ||
try { | ||
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function _createForOfIteratorHelper(o, allowArrayLike) { | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (!it) { | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
var F = function () {}; | ||
return { | ||
s: F, | ||
n: function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}, | ||
e: function (e) { | ||
throw e; | ||
}, | ||
f: F | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var normalCompletion = true, | ||
didErr = false, | ||
err; | ||
return { | ||
s: function () { | ||
it = it.call(o); | ||
}, | ||
n: function () { | ||
var step = it.next(); | ||
normalCompletion = step.done; | ||
return step; | ||
}, | ||
e: function (e) { | ||
didErr = true; | ||
err = e; | ||
}, | ||
f: function () { | ||
try { | ||
if (!normalCompletion && it.return != null) it.return(); | ||
} finally { | ||
if (didErr) throw err; | ||
} | ||
} | ||
}; | ||
} | ||
exports.arrayLikeToArray = _arrayLikeToArray; | ||
exports.arrayWithHoles = _arrayWithHoles; | ||
exports.asyncToGenerator = _asyncToGenerator; | ||
exports.createForOfIteratorHelper = _createForOfIteratorHelper; | ||
exports.iterableToArrayLimit = _iterableToArrayLimit; | ||
exports.nonIterableRest = _nonIterableRest; | ||
exports.slicedToArray = _slicedToArray; | ||
exports.unsupportedIterableToArray = _unsupportedIterableToArray; |
@@ -8,13 +8,13 @@ 'use strict'; | ||
function createRemoteSubscribable(subscription) { | ||
var initial = subscription.current; | ||
const initial = subscription.current; | ||
return { | ||
initial: initial, | ||
subscribe: function subscribe(subscriber) { | ||
initial, | ||
subscribe(subscriber) { | ||
rpc.retain(subscriber); | ||
var unsubscribe = subscription.subscribe(function () { | ||
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : subscription.current; | ||
const unsubscribe = subscription.subscribe((value = subscription.current) => { | ||
subscriber(value); | ||
}); | ||
var teardown = function teardown() { | ||
const teardown = () => { | ||
unsubscribe(); | ||
@@ -26,2 +26,3 @@ rpc.release(subscriber); | ||
} | ||
}; | ||
@@ -28,0 +29,0 @@ } |
@@ -13,7 +13,7 @@ 'use strict'; | ||
rpc.retain(subscription); | ||
var current = subscription.initial; | ||
var listening = true; | ||
var hasUpdated = false; | ||
var subscribers = new Set(); | ||
var subscriptionResult = Promise.resolve(subscription.subscribe(listener)).then(function (result) { | ||
let current = subscription.initial; | ||
let listening = true; | ||
let hasUpdated = false; | ||
const subscribers = new Set(); | ||
const subscriptionResult = Promise.resolve(subscription.subscribe(listener)).then(result => { | ||
// Because of the async nature of receiving the result, we may have | ||
@@ -31,36 +31,19 @@ // already started receiving updates from the subscriber before this | ||
subscribe: function subscribe(subscriber) { | ||
subscribe(subscriber) { | ||
subscribers.add(subscriber); | ||
return function () { | ||
return () => { | ||
subscribers.delete(subscriber); | ||
}; | ||
}, | ||
destroy: function destroy() { | ||
return _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { | ||
var _yield$subscriptionRe, _yield$subscriptionRe2, unsubscribe; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
listening = false; | ||
subscribers.clear(); | ||
_context.next = 4; | ||
return subscriptionResult; | ||
destroy() { | ||
return _rollupPluginBabelHelpers.asyncToGenerator(function* () { | ||
listening = false; | ||
subscribers.clear(); | ||
const [unsubscribe] = yield subscriptionResult; | ||
unsubscribe(); | ||
rpc.release(subscription); | ||
})(); | ||
} | ||
case 4: | ||
_yield$subscriptionRe = _context.sent; | ||
_yield$subscriptionRe2 = _rollupPluginBabelHelpers.slicedToArray(_yield$subscriptionRe, 1); | ||
unsubscribe = _yield$subscriptionRe2[0]; | ||
unsubscribe(); | ||
rpc.release(subscription); | ||
case 9: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
}))(); | ||
} | ||
}; | ||
@@ -73,14 +56,4 @@ | ||
var _iterator = _rollupPluginBabelHelpers.createForOfIteratorHelper(subscribers), | ||
_step; | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var subscriber = _step.value; | ||
subscriber(current); | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
for (const subscriber of subscribers) { | ||
subscriber(current); | ||
} | ||
@@ -87,0 +60,0 @@ } |
@@ -37,118 +37,2 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); | ||
if (_i == null) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _s, _e; | ||
try { | ||
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function _createForOfIteratorHelper(o, allowArrayLike) { | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (!it) { | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
var F = function () {}; | ||
return { | ||
s: F, | ||
n: function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}, | ||
e: function (e) { | ||
throw e; | ||
}, | ||
f: F | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var normalCompletion = true, | ||
didErr = false, | ||
err; | ||
return { | ||
s: function () { | ||
it = it.call(o); | ||
}, | ||
n: function () { | ||
var step = it.next(); | ||
normalCompletion = step.done; | ||
return step; | ||
}, | ||
e: function (e) { | ||
didErr = true; | ||
err = e; | ||
}, | ||
f: function () { | ||
try { | ||
if (!normalCompletion && it.return != null) it.return(); | ||
} finally { | ||
if (didErr) throw err; | ||
} | ||
} | ||
}; | ||
} | ||
export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _asyncToGenerator as asyncToGenerator, _createForOfIteratorHelper as createForOfIteratorHelper, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _slicedToArray as slicedToArray, _unsupportedIterableToArray as unsupportedIterableToArray }; | ||
export { _asyncToGenerator as asyncToGenerator }; |
@@ -1,1 +0,4 @@ | ||
module.exports = require("./build/cjs/index.js"); | ||
function interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
module.exports = interopRequireDefault(require("./build/cjs/index.js")); |
{ | ||
"name": "@remote-ui/async-subscription", | ||
"version": "2.1.6", | ||
"version": "2.1.7", | ||
"publishConfig": { | ||
@@ -12,3 +12,3 @@ "access": "public", | ||
"esnext": "index.esnext", | ||
"types": "index.d.ts", | ||
"types": "./build/ts/index.d.ts", | ||
"exports": { | ||
@@ -24,5 +24,5 @@ ".": { | ||
"dependencies": { | ||
"@remote-ui/rpc": "^1.2.4" | ||
"@remote-ui/rpc": "^1.2.5" | ||
}, | ||
"gitHead": "a368dedfaffc353f2fbfff30fc9c4e80493ba22a" | ||
"gitHead": "797aace1ef0a7b5f4da58da1314500fd7ce60c80" | ||
} |
import {retain, release} from '@remote-ui/rpc'; | ||
import type {SyncSubscribable, RemoteSubscribable} from './types'; | ||
@@ -3,0 +4,0 @@ |
import {retain, release} from '@remote-ui/rpc'; | ||
import type { | ||
@@ -3,0 +4,0 @@ Subscriber, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
59937
41
551
Updated@remote-ui/rpc@^1.2.5