| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 | 'use strict';Object.defineProperty(exports, '__esModule', { value: true });var utils = require('./utils.js');function createNotifyManager() {  let queue = [];  let transactions = 0;  let notifyFn = callback => {    callback();  };  let batchNotifyFn = callback => {    callback();  };  const batch = callback => {    let result;    transactions++;    try {      result = callback();    } finally {      transactions--;      if (!transactions) {        flush();      }    }    return result;  };  const schedule = callback => {    if (transactions) {      queue.push(callback);    } else {      utils.scheduleMicrotask(() => {        notifyFn(callback);      });    }  };  /**   * All calls to the wrapped function will be batched.   */  const batchCalls = callback => {    return (...args) => {      schedule(() => {        callback(...args);      });    };  };  const flush = () => {    const originalQueue = queue;    queue = [];    if (originalQueue.length) {      utils.scheduleMicrotask(() => {        batchNotifyFn(() => {          originalQueue.forEach(callback => {            notifyFn(callback);          });        });      });    }  };  /**   * Use this method to set a custom notify function.   * This can be used to for example wrap notifications with `React.act` while running tests.   */  const setNotifyFunction = fn => {    notifyFn = fn;  };  /**   * Use this method to set a custom function to batch notifications together into a single tick.   * By default React Query will use the batch function provided by ReactDOM or React Native.   */  const setBatchNotifyFunction = fn => {    batchNotifyFn = fn;  };  return {    batch,    batchCalls,    schedule,    setNotifyFunction,    setBatchNotifyFunction  };} // SINGLETONconst notifyManager = createNotifyManager();exports.createNotifyManager = createNotifyManager;exports.notifyManager = notifyManager;//# sourceMappingURL=notifyManager.js.map
 |