"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.configMobx = configMobx;
const mobx_1 = require("mobx");
function createAsyncUpdateScheduler() {
    let pending = false;
    const reactionQueue = [];
    return (f) => {
        reactionQueue.push(f);
        if (!pending) {
            pending = true;
            Promise.resolve().then(() => {
                const reactions = reactionQueue.slice();
                reactionQueue.length = 0;
                pending = false;
                reactions.forEach((reaction) => typeof reaction === 'function' && reaction());
            });
        }
    };
}
function configMobx() {
    const scheduler = createAsyncUpdateScheduler();
    (0, mobx_1.configure)({
        enforceActions: 'never',
        reactionScheduler: scheduler,
    });
}
