'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.unload = unload;
exports.initGlobalHandlers = initGlobalHandlers;

var _shutdown = require('./kernel/shutdown');

/**
export function beforeUnload(store, dispatch, e) {
}
*/

function unload(store) {
  const state = store.getState();
  const kernel = {
    channels: state.app.channels,
    spawn: state.app.spawn,
    connectionFile: state.app.connectionFile
  };
  (0, _shutdown.forceShutdownKernel)(kernel);
}

function initGlobalHandlers(store) {
  // TODO: use beforeunload to ask user to save
  // global.window.onbeforeunload = beforeUnload.bind(null, store, dispatch);
  global.window.onunload = unload.bind(null, store);
}