createReactiveState = ({stateKey, schema, defaultValue, skipDuplicate}) => {
  if (reactiveStates[stateKey]) {
    if (skipDuplicate) return reactiveStates[stateKey];
    throw new Error(`There is already a reactive state named ${stateKey}`);
  }

  if (schema) {
    schema = createSchema(schema);
    defaultValue = cleanReactiveStateValue(defaultValue || {}, schema);
  }

  const reactiveVar = makeVar(defaultValue);

  const reactiveState = function (updates) {
    let value = reactiveVar();
    if (arguments.length > 0) {
      if (typeof updates === 'function') {
        value = updates(value);
      } else if (typeof value === 'object' && typeof updates === 'object') {
        value = Object.assign({}, value, updates);
      } else if (value === null) {
        value = defaultValue;
      } else {
        value = updates;
      }
      value = cleanReactiveStateValue(value, schema);
      value = reactiveVar(value);
    }
    return value;
  };
  reactiveState.stateKey = stateKey;
  reactiveState.schema = schema;
  reactiveState.defaultValue = defaultValue;
  reactiveState.reactiveVar = reactiveVar;

  reactiveStates[stateKey] = reactiveState;

  return reactiveState;
}
Create a new reactive state
@param {string} stateKey The name/id/key for the new reactive state
@param {Object|SimpleSchema} [schema] Optional schema definition object that will be converted to `SimpleSchema`
  using `createSchema()`
@param {*} [defaultValue] Optional default value; alternatively you can define `defaultValue`s in the schema
@param {boolean} [skipDuplicate] If you try to create a reactive state with a key that's already used, an exception
  will be thrown; use this option to prevent the exception and use the existing state without changing it
@returns {ReactiveState} Returns the newly created state object
@throws Will throw an error if there is already a reactive state with the given key - unless `skipDuplicates` is `true`