{"version":3,"sources":["../../src/observable.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { ObservableLike, SubscriptionObserver } from 'observable-fns'\nimport { Observable } from 'observable-fns'\n\nconst $observers = Symbol('observers')\n\n/**\n * Observable subject. Implements the Observable interface, but also exposes\n * the `next()`, `error()`, `complete()` methods to initiate observable\n * updates \"from the outside\".\n *\n * Use `Observable.from(subject)` to derive an observable that proxies all\n * values, errors and the completion raised on this subject, but does not\n * expose the `next()`, `error()`, `complete()` methods.\n */\nexport class Subject<T> extends Observable<T> implements ObservableLike<T> {\n  private [$observers]: Array<SubscriptionObserver<T>>\n\n  constructor() {\n    super((observer) => {\n      this[$observers] = [...(this[$observers] || []), observer]\n      const unsubscribe = () => {\n        this[$observers] = this[$observers].filter(someObserver => someObserver !== observer)\n      }\n      return unsubscribe\n    })\n\n    this[$observers] = []\n  }\n\n  complete() {\n    for (const observer of this[$observers]) observer.complete()\n  }\n\n  error(error: any) {\n    for (const observer of this[$observers]) observer.error(error)\n  }\n\n  next(value: T) {\n    for (const observer of this[$observers]) observer.next(value)\n  }\n}\n\nexport { Observable } from 'observable-fns'\n"],"mappings":";AAEA,SAAS,kBAAkB;AAyC3B,SAAS,cAAAA,mBAAkB;AAvC3B,IAAM,aAAa,OAAO,WAAW;AAW9B,IAAM,UAAN,cAAyB,WAA2C;AAAA,EACzE,CAAS,UAAU;AAAA,EAEnB,cAAc;AACZ,UAAM,CAAC,aAAa;AAClB,WAAK,UAAU,IAAI,CAAC,GAAI,KAAK,UAAU,KAAK,CAAC,GAAI,QAAQ;AACzD,YAAM,cAAc,MAAM;AACxB,aAAK,UAAU,IAAI,KAAK,UAAU,EAAE,OAAO,kBAAgB,iBAAiB,QAAQ;AAAA,MACtF;AACA,aAAO;AAAA,IACT,CAAC;AAED,SAAK,UAAU,IAAI,CAAC;AAAA,EACtB;AAAA,EAEA,WAAW;AACT,eAAW,YAAY,KAAK,UAAU,EAAG,UAAS,SAAS;AAAA,EAC7D;AAAA,EAEA,MAAM,OAAY;AAChB,eAAW,YAAY,KAAK,UAAU,EAAG,UAAS,MAAM,KAAK;AAAA,EAC/D;AAAA,EAEA,KAAK,OAAU;AACb,eAAW,YAAY,KAAK,UAAU,EAAG,UAAS,KAAK,KAAK;AAAA,EAC9D;AACF;","names":["Observable"]}