'use strict';

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

var vue = require('vue');

function useSyncState(defaultState, onChange) {
  const stateRef = vue.ref(defaultState);
  function setState(updater) {
    const newValue = typeof updater === "function" ? updater(stateRef.value) : updater;
    if (newValue !== stateRef.value)
      onChange(newValue, stateRef.value);
    stateRef.value = newValue;
  }
  return [stateRef, setState];
}

exports.default = useSyncState;
//# sourceMappingURL=useSyncState.cjs.map
