
export default function observe() {
  const listeners = [];

  const subscribe = (fn) => {
    listeners.push(fn);

    return () => listeners.splice(listeners.indexOf(fn), 1)
  }

  const notify = (...args) => {
    listeners.forEach(fn => fn(...args))
  }

  return {
    subscribe,
    notify,
  }
}
