class Subscribable {
  _listeners = /* @__PURE__ */ new Set();
  /**
   * Subscribe to the subscribable.
   *
   * @param listener - The listener to subscribe to.
   * @returns A function to unsubscribe from the subscribable.
   */
  subscribe = (listener) => {
    this._listeners.add(listener);
    return () => {
      this._listeners.delete(listener);
    };
  };
  /**
   * Notify all listeners.
   *
   * @param update - The update to notify listeners with.
   */
  notify = (update) => {
    this._listeners.forEach((listener) => listener(update));
  };
  hasListeners = () => this._listeners.size > 0;
  /**
   * Unsubscribe all listeners.
   */
  cleanup = () => {
    this._listeners.clear();
  };
}
export {
  Subscribable
};
//# sourceMappingURL=subscribable.js.map
