react-native-onyx 1.0.129 → 1.0.131
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/README.md +0 -8
- package/dist/web.development.js +2 -287
- package/dist/web.development.js.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/lib/Onyx.d.ts +2 -12
- package/lib/Onyx.js +1 -106
- package/lib/Str.js +1 -16
- package/lib/utils.d.ts +2 -2
- package/package.json +8 -12
- package/lib/ActiveClientManager/index.d.ts +0 -22
- package/lib/ActiveClientManager/index.native.js +0 -18
- package/lib/ActiveClientManager/index.web.js +0 -94
- package/lib/broadcast/index.d.ts +0 -17
- package/lib/broadcast/index.native.js +0 -12
- package/lib/broadcast/index.web.js +0 -33
package/README.md
CHANGED
|
@@ -443,11 +443,3 @@ To continuously work on Onyx we have to set up a task that copies content to par
|
|
|
443
443
|
3. Optional: run `npm run build` (if you're working or want to test on a non react-native project)
|
|
444
444
|
- `npm link` would actually work outside of `react-native` and it can be used to link Onyx locally for a web only project
|
|
445
445
|
4. Copy Onyx to consumer project's `node_modules/react-native-onyx`
|
|
446
|
-
|
|
447
|
-
# Automated Tests
|
|
448
|
-
|
|
449
|
-
There are Playwright e2e tests implemented for the web. To run them:
|
|
450
|
-
|
|
451
|
-
- in the tests/e2e/app directory, run `npm install`
|
|
452
|
-
- `npm run e2e` to run the e2e tests
|
|
453
|
-
- or `npm run e2e-ui` to run the e2e tests in UI mode
|
package/dist/web.development.js
CHANGED
|
@@ -11,119 +11,6 @@
|
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ var __webpack_modules__ = ({
|
|
13
13
|
|
|
14
|
-
/***/ "./lib/ActiveClientManager/index.web.js":
|
|
15
|
-
/*!**********************************************!*\
|
|
16
|
-
!*** ./lib/ActiveClientManager/index.web.js ***!
|
|
17
|
-
\**********************************************/
|
|
18
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
19
|
-
|
|
20
|
-
"use strict";
|
|
21
|
-
__webpack_require__.r(__webpack_exports__);
|
|
22
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23
|
-
/* harmony export */ "init": () => (/* binding */ init),
|
|
24
|
-
/* harmony export */ "isClientTheLeader": () => (/* binding */ isClientTheLeader),
|
|
25
|
-
/* harmony export */ "isReady": () => (/* binding */ isReady),
|
|
26
|
-
/* harmony export */ "subscribeToClientChange": () => (/* binding */ subscribeToClientChange)
|
|
27
|
-
/* harmony export */ });
|
|
28
|
-
/* harmony import */ var _Str__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Str */ "./lib/Str.js");
|
|
29
|
-
/* harmony import */ var _broadcast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../broadcast */ "./lib/broadcast/index.web.js");
|
|
30
|
-
/**
|
|
31
|
-
* When you have many tabs in one browser, the data of Onyx is shared between all of them. Since we persist write requests in Onyx, we need to ensure that
|
|
32
|
-
* only one tab is processing those saved requests or we would be duplicating data (or creating errors).
|
|
33
|
-
* This file ensures exactly that by tracking all the clientIDs connected, storing the most recent one last and it considers that last clientID the "leader".
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const NEW_LEADER_MESSAGE = 'NEW_LEADER';
|
|
40
|
-
const REMOVED_LEADER_MESSAGE = 'REMOVE_LEADER';
|
|
41
|
-
|
|
42
|
-
const clientID = _Str__WEBPACK_IMPORTED_MODULE_0__.guid();
|
|
43
|
-
const subscribers = [];
|
|
44
|
-
let timestamp = null;
|
|
45
|
-
|
|
46
|
-
let activeClientID = null;
|
|
47
|
-
let setIsReady = () => {};
|
|
48
|
-
const isReadyPromise = new Promise((resolve) => {
|
|
49
|
-
setIsReady = resolve;
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Determines when the client is ready. We need to wait both till we saved our ID in onyx AND the init method was called
|
|
54
|
-
* @returns {Promise}
|
|
55
|
-
*/
|
|
56
|
-
function isReady() {
|
|
57
|
-
return isReadyPromise;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Returns a boolean indicating if the current client is the leader.
|
|
62
|
-
*
|
|
63
|
-
* @returns {Boolean}
|
|
64
|
-
*/
|
|
65
|
-
function isClientTheLeader() {
|
|
66
|
-
return activeClientID === clientID;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Subscribes to when the client changes.
|
|
71
|
-
* @param {Function} callback
|
|
72
|
-
*/
|
|
73
|
-
function subscribeToClientChange(callback) {
|
|
74
|
-
subscribers.push(callback);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Subscribe to the broadcast channel to listen for messages from other tabs, so that
|
|
79
|
-
* all tabs agree on who the leader is, which should always be the last tab to open.
|
|
80
|
-
*/
|
|
81
|
-
function init() {
|
|
82
|
-
_broadcast__WEBPACK_IMPORTED_MODULE_1__.subscribe((message) => {
|
|
83
|
-
switch (message.data.type) {
|
|
84
|
-
case NEW_LEADER_MESSAGE:{
|
|
85
|
-
// Only update the active leader if the message received was from another
|
|
86
|
-
// tab that initialized after the current one; if the timestamps are the
|
|
87
|
-
// same, it uses the client ID to tie-break
|
|
88
|
-
const isTimestampEqual = timestamp === message.data.timestamp;
|
|
89
|
-
const isTimestampNewer = timestamp > message.data.timestamp;
|
|
90
|
-
if (isClientTheLeader() && (isTimestampNewer || isTimestampEqual && clientID > message.data.clientID)) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
activeClientID = message.data.clientID;
|
|
94
|
-
|
|
95
|
-
subscribers.forEach((callback) => callback());
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
case REMOVED_LEADER_MESSAGE:
|
|
99
|
-
activeClientID = clientID;
|
|
100
|
-
timestamp = Date.now();
|
|
101
|
-
_broadcast__WEBPACK_IMPORTED_MODULE_1__.sendMessage({ type: NEW_LEADER_MESSAGE, clientID, timestamp });
|
|
102
|
-
subscribers.forEach((callback) => callback());
|
|
103
|
-
break;
|
|
104
|
-
default:
|
|
105
|
-
break;}
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
activeClientID = clientID;
|
|
110
|
-
timestamp = Date.now();
|
|
111
|
-
|
|
112
|
-
_broadcast__WEBPACK_IMPORTED_MODULE_1__.sendMessage({ type: NEW_LEADER_MESSAGE, clientID, timestamp });
|
|
113
|
-
setIsReady();
|
|
114
|
-
|
|
115
|
-
window.addEventListener('beforeunload', () => {
|
|
116
|
-
if (!isClientTheLeader()) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
_broadcast__WEBPACK_IMPORTED_MODULE_1__.sendMessage({ type: REMOVED_LEADER_MESSAGE, clientID });
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
/***/ }),
|
|
126
|
-
|
|
127
14
|
/***/ "./lib/DevTools.js":
|
|
128
15
|
/*!*************************!*\
|
|
129
16
|
!*** ./lib/DevTools.js ***!
|
|
@@ -279,8 +166,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
279
166
|
/* harmony import */ var _createDeferredTask__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./createDeferredTask */ "./lib/createDeferredTask.js");
|
|
280
167
|
/* harmony import */ var _metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./metrics/PerformanceUtils */ "./lib/metrics/PerformanceUtils.js");
|
|
281
168
|
/* harmony import */ var _storage__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./storage */ "./lib/storage/index.web.js");
|
|
282
|
-
/* harmony import */ var _broadcast__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./broadcast */ "./lib/broadcast/index.web.js");
|
|
283
|
-
/* harmony import */ var _ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ActiveClientManager */ "./lib/ActiveClientManager/index.web.js");
|
|
284
169
|
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ "./lib/utils.js");
|
|
285
170
|
/* harmony import */ var _batch__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./batch */ "./lib/batch.js");
|
|
286
171
|
/* harmony import */ var _DevTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DevTools */ "./lib/DevTools.js");
|
|
@@ -297,8 +182,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
297
182
|
|
|
298
183
|
|
|
299
184
|
|
|
300
|
-
|
|
301
|
-
|
|
302
185
|
// Method constants
|
|
303
186
|
const METHOD = {
|
|
304
187
|
SET: 'set',
|
|
@@ -308,8 +191,6 @@ const METHOD = {
|
|
|
308
191
|
CLEAR: 'clear'
|
|
309
192
|
};
|
|
310
193
|
|
|
311
|
-
const ON_CLEAR = 'on_clear';
|
|
312
|
-
|
|
313
194
|
// Key/value store of Onyx key and arrays of values to merge
|
|
314
195
|
const mergeQueue = {};
|
|
315
196
|
const mergeQueuePromise = {};
|
|
@@ -340,12 +221,6 @@ let defaultKeyStates = {};
|
|
|
340
221
|
// Connections can be made before `Onyx.init`. They would wait for this task before resolving
|
|
341
222
|
const deferredInitTask = (0,_createDeferredTask__WEBPACK_IMPORTED_MODULE_2__["default"])();
|
|
342
223
|
|
|
343
|
-
// The promise of the clear function, saved so that no writes happen while it's executing
|
|
344
|
-
let isClearing = false;
|
|
345
|
-
|
|
346
|
-
// Callback to be executed after the clear execution ends
|
|
347
|
-
let onClearCallback = null;
|
|
348
|
-
|
|
349
224
|
let batchUpdatesPromise = null;
|
|
350
225
|
let batchUpdatesQueue = [];
|
|
351
226
|
|
|
@@ -1376,15 +1251,6 @@ function removeNullValues(key, value) {
|
|
|
1376
1251
|
* @returns {Promise}
|
|
1377
1252
|
*/
|
|
1378
1253
|
function set(key, value) {
|
|
1379
|
-
if (!_ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.isClientTheLeader()) {
|
|
1380
|
-
_broadcast__WEBPACK_IMPORTED_MODULE_12__.sendMessage({ type: METHOD.SET, key, value });
|
|
1381
|
-
return Promise.resolve();
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
if (isClearing) {
|
|
1385
|
-
return Promise.resolve();
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
1254
|
// If the value is null, we remove the key from storage
|
|
1389
1255
|
const { value: valueAfterRemoving, wasRemoved } = removeNullValues(key, value);
|
|
1390
1256
|
|
|
@@ -1441,15 +1307,6 @@ function prepareKeyValuePairsForStorage(data) {
|
|
|
1441
1307
|
* @returns {Promise}
|
|
1442
1308
|
*/
|
|
1443
1309
|
function multiSet(data) {
|
|
1444
|
-
if (!_ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.isClientTheLeader()) {
|
|
1445
|
-
_broadcast__WEBPACK_IMPORTED_MODULE_12__.sendMessage({ type: METHOD.MULTI_SET, data });
|
|
1446
|
-
return Promise.resolve();
|
|
1447
|
-
}
|
|
1448
|
-
|
|
1449
|
-
if (isClearing) {
|
|
1450
|
-
return Promise.resolve();
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
1310
|
const keyValuePairs = prepareKeyValuePairsForStorage(data);
|
|
1454
1311
|
|
|
1455
1312
|
const updatePromises = underscore__WEBPACK_IMPORTED_MODULE_1___default().map(keyValuePairs, (_ref2) => {let [key, value] = _ref2;
|
|
@@ -1513,15 +1370,6 @@ function applyMerge(existingValue, changes, shouldRemoveNullObjectValues) {
|
|
|
1513
1370
|
* @returns {Promise}
|
|
1514
1371
|
*/
|
|
1515
1372
|
function merge(key, changes) {
|
|
1516
|
-
if (!_ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.isClientTheLeader()) {
|
|
1517
|
-
_broadcast__WEBPACK_IMPORTED_MODULE_12__.sendMessage({ type: METHOD.MERGE, key, changes });
|
|
1518
|
-
return Promise.resolve();
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
if (isClearing) {
|
|
1522
|
-
return Promise.resolve();
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
1373
|
// Top-level undefined values are ignored
|
|
1526
1374
|
// Therefore we need to prevent adding them to the merge queue
|
|
1527
1375
|
if (underscore__WEBPACK_IMPORTED_MODULE_1___default().isUndefined(changes)) {
|
|
@@ -1575,7 +1423,7 @@ function merge(key, changes) {
|
|
|
1575
1423
|
const updatePromise = broadcastUpdate(key, modifiedData, 'merge', hasChanged, wasRemoved);
|
|
1576
1424
|
|
|
1577
1425
|
// If the value has not changed, calling Storage.setItem() would be redundant and a waste of performance, so return early instead.
|
|
1578
|
-
if (!hasChanged ||
|
|
1426
|
+
if (!hasChanged || wasRemoved) {
|
|
1579
1427
|
return updatePromise;
|
|
1580
1428
|
}
|
|
1581
1429
|
|
|
@@ -1630,17 +1478,6 @@ function initializeWithDefaultKeyStates() {
|
|
|
1630
1478
|
* @returns {Promise<void>}
|
|
1631
1479
|
*/
|
|
1632
1480
|
function clear() {let keysToPreserve = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1633
|
-
if (!_ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.isClientTheLeader()) {
|
|
1634
|
-
_broadcast__WEBPACK_IMPORTED_MODULE_12__.sendMessage({ type: METHOD.CLEAR, keysToPreserve });
|
|
1635
|
-
return Promise.resolve();
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
if (isClearing) {
|
|
1639
|
-
return Promise.resolve();
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
|
-
isClearing = true;
|
|
1643
|
-
|
|
1644
1481
|
return getAllKeys().then((keys) => {
|
|
1645
1482
|
const keysToBeClearedFromStorage = [];
|
|
1646
1483
|
const keyValuesToResetAsCollection = {};
|
|
@@ -1701,8 +1538,6 @@ function clear() {let keysToPreserve = arguments.length > 0 && arguments[0] !==
|
|
|
1701
1538
|
return _storage__WEBPACK_IMPORTED_MODULE_7__["default"].removeItems(keysToBeClearedFromStorage).
|
|
1702
1539
|
then(() => _storage__WEBPACK_IMPORTED_MODULE_7__["default"].multiSet(defaultKeyValuePairs)).
|
|
1703
1540
|
then(() => {
|
|
1704
|
-
isClearing = false;
|
|
1705
|
-
_broadcast__WEBPACK_IMPORTED_MODULE_12__.sendMessage({ type: METHOD.CLEAR, keysToPreserve });
|
|
1706
1541
|
_DevTools__WEBPACK_IMPORTED_MODULE_3__["default"].clearState(keysToPreserve);
|
|
1707
1542
|
return Promise.all(updatePromises);
|
|
1708
1543
|
});
|
|
@@ -1857,48 +1692,6 @@ function setMemoryOnlyKeys(keyList) {
|
|
|
1857
1692
|
_OnyxCache__WEBPACK_IMPORTED_MODULE_6__["default"].setRecentKeysLimit(Infinity);
|
|
1858
1693
|
}
|
|
1859
1694
|
|
|
1860
|
-
/**
|
|
1861
|
-
* Sets the callback to be called when the clear finishes executing.
|
|
1862
|
-
* @param {Function} callback
|
|
1863
|
-
*/
|
|
1864
|
-
function onClear(callback) {
|
|
1865
|
-
onClearCallback = callback;
|
|
1866
|
-
}
|
|
1867
|
-
|
|
1868
|
-
/**
|
|
1869
|
-
* Subscribes to the Broadcast channel and executes actions based on the
|
|
1870
|
-
* types of events.
|
|
1871
|
-
*/
|
|
1872
|
-
function subscribeToEvents() {
|
|
1873
|
-
_broadcast__WEBPACK_IMPORTED_MODULE_12__.subscribe((_ref5) => {let { data } = _ref5;
|
|
1874
|
-
if (!_ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.isClientTheLeader()) {
|
|
1875
|
-
return;
|
|
1876
|
-
}
|
|
1877
|
-
switch (data.type) {
|
|
1878
|
-
case METHOD.CLEAR:
|
|
1879
|
-
clear(data.keysToPreserve);
|
|
1880
|
-
break;
|
|
1881
|
-
case METHOD.SET:
|
|
1882
|
-
set(data.key, data.value);
|
|
1883
|
-
break;
|
|
1884
|
-
case METHOD.MULTI_SET:
|
|
1885
|
-
multiSet(data.key, data.value);
|
|
1886
|
-
break;
|
|
1887
|
-
case METHOD.MERGE:
|
|
1888
|
-
merge(data.key, data.changes);
|
|
1889
|
-
break;
|
|
1890
|
-
case ON_CLEAR:
|
|
1891
|
-
if (!onClearCallback) {
|
|
1892
|
-
break;
|
|
1893
|
-
}
|
|
1894
|
-
onClearCallback();
|
|
1895
|
-
break;
|
|
1896
|
-
default:
|
|
1897
|
-
break;}
|
|
1898
|
-
|
|
1899
|
-
});
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
1695
|
/**
|
|
1903
1696
|
* Initialize the store with actions and listening for storage events
|
|
1904
1697
|
*
|
|
@@ -1933,15 +1726,6 @@ function init()
|
|
|
1933
1726
|
|
|
1934
1727
|
|
|
1935
1728
|
{let { keys = {}, initialKeyStates = {}, safeEvictionKeys = [], maxCachedKeysCount = 1000, captureMetrics = false, shouldSyncMultipleInstances = Boolean(__webpack_require__.g.localStorage), debugSetState = false } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1936
|
-
_ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.init();
|
|
1937
|
-
|
|
1938
|
-
_ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.isReady().then(() => {
|
|
1939
|
-
if (!_ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.isClientTheLeader()) {
|
|
1940
|
-
return;
|
|
1941
|
-
}
|
|
1942
|
-
subscribeToEvents();
|
|
1943
|
-
});
|
|
1944
|
-
|
|
1945
1729
|
if (captureMetrics) {
|
|
1946
1730
|
// The code here is only bundled and applied when the captureMetrics is set
|
|
1947
1731
|
// eslint-disable-next-line no-use-before-define
|
|
@@ -2005,11 +1789,7 @@ const Onyx = {
|
|
|
2005
1789
|
METHOD,
|
|
2006
1790
|
setMemoryOnlyKeys,
|
|
2007
1791
|
tryGetCachedValue,
|
|
2008
|
-
hasPendingMergeForKey
|
|
2009
|
-
onClear,
|
|
2010
|
-
isClientManagerReady: _ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.isReady,
|
|
2011
|
-
isClientTheLeader: _ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.isClientTheLeader,
|
|
2012
|
-
subscribeToClientChange: _ActiveClientManager__WEBPACK_IMPORTED_MODULE_11__.subscribeToClientChange
|
|
1792
|
+
hasPendingMergeForKey
|
|
2013
1793
|
};
|
|
2014
1794
|
|
|
2015
1795
|
/**
|
|
@@ -2315,7 +2095,6 @@ const instance = new OnyxCache();
|
|
|
2315
2095
|
"use strict";
|
|
2316
2096
|
__webpack_require__.r(__webpack_exports__);
|
|
2317
2097
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2318
|
-
/* harmony export */ "guid": () => (/* binding */ guid),
|
|
2319
2098
|
/* harmony export */ "result": () => (/* binding */ result),
|
|
2320
2099
|
/* harmony export */ "startsWith": () => (/* binding */ startsWith)
|
|
2321
2100
|
/* harmony export */ });
|
|
@@ -2347,21 +2126,6 @@ function result(parameter) {for (var _len = arguments.length, args = new Array(_
|
|
|
2347
2126
|
return underscore__WEBPACK_IMPORTED_MODULE_0___default().isFunction(parameter) ? parameter(...args) : parameter;
|
|
2348
2127
|
}
|
|
2349
2128
|
|
|
2350
|
-
/**
|
|
2351
|
-
* A simple GUID generator taken from https://stackoverflow.com/a/32760401/9114791
|
|
2352
|
-
*
|
|
2353
|
-
* @param {String} [prefix] an optional prefix to put in front of the guid
|
|
2354
|
-
* @returns {String}
|
|
2355
|
-
*/
|
|
2356
|
-
function guid() {let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
2357
|
-
function s4() {
|
|
2358
|
-
return Math.floor((1 + Math.random()) * 0x10000).
|
|
2359
|
-
toString(16).
|
|
2360
|
-
substring(1);
|
|
2361
|
-
}
|
|
2362
|
-
return `${prefix}${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
|
|
2363
|
-
}
|
|
2364
|
-
|
|
2365
2129
|
|
|
2366
2130
|
|
|
2367
2131
|
/***/ }),
|
|
@@ -2383,55 +2147,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2383
2147
|
|
|
2384
2148
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (react_dom__WEBPACK_IMPORTED_MODULE_0__.unstable_batchedUpdates);
|
|
2385
2149
|
|
|
2386
|
-
/***/ }),
|
|
2387
|
-
|
|
2388
|
-
/***/ "./lib/broadcast/index.web.js":
|
|
2389
|
-
/*!************************************!*\
|
|
2390
|
-
!*** ./lib/broadcast/index.web.js ***!
|
|
2391
|
-
\************************************/
|
|
2392
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2393
|
-
|
|
2394
|
-
"use strict";
|
|
2395
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2396
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2397
|
-
/* harmony export */ "disconnect": () => (/* binding */ disconnect),
|
|
2398
|
-
/* harmony export */ "sendMessage": () => (/* binding */ sendMessage),
|
|
2399
|
-
/* harmony export */ "subscribe": () => (/* binding */ subscribe)
|
|
2400
|
-
/* harmony export */ });
|
|
2401
|
-
const BROADCAST_ONYX = 'BROADCAST_ONYX';
|
|
2402
|
-
|
|
2403
|
-
const subscriptions = [];
|
|
2404
|
-
const channel = new BroadcastChannel(BROADCAST_ONYX);
|
|
2405
|
-
|
|
2406
|
-
/**
|
|
2407
|
-
* Sends a message to the broadcast channel.
|
|
2408
|
-
* @param {String} message
|
|
2409
|
-
*/
|
|
2410
|
-
function sendMessage(message) {
|
|
2411
|
-
channel.postMessage(message);
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
/**
|
|
2415
|
-
* Subscribes to the broadcast channel. Every time a new message
|
|
2416
|
-
* is received, the callback is called.
|
|
2417
|
-
* @param {Function} callback
|
|
2418
|
-
*/
|
|
2419
|
-
function subscribe(callback) {
|
|
2420
|
-
subscriptions.push(callback);
|
|
2421
|
-
channel.onmessage = (message) => {
|
|
2422
|
-
subscriptions.forEach((c) => c(message));
|
|
2423
|
-
};
|
|
2424
|
-
}
|
|
2425
|
-
|
|
2426
|
-
/**
|
|
2427
|
-
* Disconnects from the broadcast channel.
|
|
2428
|
-
*/
|
|
2429
|
-
function disconnect() {
|
|
2430
|
-
channel.close();
|
|
2431
|
-
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
2150
|
/***/ }),
|
|
2436
2151
|
|
|
2437
2152
|
/***/ "./lib/createDeferredTask.js":
|