import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { atom, useRecoilState } from "recoil";
import { useCallback } from "react";
export var activeDatasetManagerState = atom({
  default: null,
  key: "datasetManager",
  dangerouslyAllowMutability: true
});
export default (function () {
  var _useRecoilState = useRecoilState(activeDatasetManagerState),
      _useRecoilState2 = _slicedToArray(_useRecoilState, 2),
      dm = _useRecoilState2[0],
      setRecoilDatasetManager = _useRecoilState2[1];

  var setDatasetManager = useCallback(function (newDM) {
    if (dm) {
      if (dm.disconnect) {
        dm.disconnect();
      } else {
        dm.emit("disconnect");
      }
    }

    setRecoilDatasetManager(newDM);
  }, [dm, setRecoilDatasetManager]);
  return [dm, setDatasetManager];
});