'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var raf = require('../../../_util/raf.js');

function useFrameSetState(initial) {
  const frame = vue.ref(null);
  const state = vue.reactive({ ...initial });
  const queue = vue.ref([]);
  const setFrameState = (newState) => {
    if (frame.value === null) {
      queue.value = [];
      frame.value = raf.default(() => {
        let memoState;
        queue.value.forEach((queueState) => {
          memoState = { ...memoState, ...queueState };
        });
        Object.assign(state, memoState);
        frame.value = null;
      });
    }
    queue.value.push(newState);
  };
  vue.onMounted(() => {
    frame.value && raf.default.cancel(frame.value);
  });
  return [state, setFrameState];
}

exports.default = useFrameSetState;
//# sourceMappingURL=useFrameSetState.js.map
