import { configure } from '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());
            });
        }
    };
}
export function configMobx() {
    const scheduler = createAsyncUpdateScheduler();
    configure({
        enforceActions: 'never',
        reactionScheduler: scheduler,
    });
}
