import _objectSpread from "@babel/runtime/helpers/objectSpread2";
export default function createStore(initialState) {
  var state = initialState;
  var listeners = [];

  function setState(partial) {
    state = _objectSpread(_objectSpread({}, state), partial);

    for (var i = 0; i < listeners.length; i++) {
      listeners[i]();
    }
  }

  function getState() {
    return state;
  }

  function subscribe(listener) {
    listeners.push(listener);
    return function unsubscribe() {
      var index = listeners.indexOf(listener);
      listeners.splice(index, 1);
    };
  }

  return {
    setState: setState,
    getState: getState,
    subscribe: subscribe
  };
}
//# sourceMappingURL=createStore.js.map
