@kithinji/orca 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1892,6 +1892,13 @@ var kithinjiorca = (() => {
1892
1892
  this.subscribers = /* @__PURE__ */ new Set();
1893
1893
  this._isCompleted = false;
1894
1894
  this._hasError = false;
1895
+ this._thrownError = null;
1896
+ }
1897
+ asObservable() {
1898
+ return new Observable((observer) => {
1899
+ const subscription = this.subscribe(observer);
1900
+ return () => subscription.unsubscribe();
1901
+ });
1895
1902
  }
1896
1903
  subscribe(observerOrNext, error, complete) {
1897
1904
  if (this._isCompleted) {
@@ -1928,16 +1935,10 @@ var kithinjiorca = (() => {
1928
1935
  error(err) {
1929
1936
  if (this._isCompleted || this._hasError) return;
1930
1937
  this._hasError = true;
1931
- const currentSubscribers = Array.from(this.subscribers);
1932
- currentSubscribers.forEach((observer) => {
1933
- if (observer.error) {
1934
- try {
1935
- observer.error(err);
1936
- } catch (e) {
1937
- console.error("Error in error handler:", e);
1938
- }
1939
- }
1940
- });
1938
+ this._thrownError = err;
1939
+ for (const observer of this.subscribers) {
1940
+ observer.error?.(err);
1941
+ }
1941
1942
  this.subscribers.clear();
1942
1943
  }
1943
1944
  complete() {
@@ -1966,22 +1967,23 @@ var kithinjiorca = (() => {
1966
1967
  get $value() {
1967
1968
  return this._value;
1968
1969
  }
1969
- setValue(value) {
1970
- this._value = value;
1971
- }
1972
1970
  next(value) {
1973
1971
  this._value = value;
1974
1972
  super.next(value);
1975
1973
  }
1976
1974
  subscribe(observerOrNext, error, complete) {
1977
1975
  const observer = typeof observerOrNext === "function" ? { next: observerOrNext, error, complete } : observerOrNext;
1978
- try {
1979
- observer.next(this._value);
1980
- } catch (err) {
1981
- if (observer.error) {
1982
- observer.error(err);
1983
- }
1976
+ if (this._hasError) {
1977
+ observer.error?.(this._thrownError);
1978
+ return { unsubscribe: () => {
1979
+ } };
1980
+ }
1981
+ if (this._isCompleted) {
1982
+ observer.complete?.();
1983
+ return { unsubscribe: () => {
1984
+ } };
1984
1985
  }
1986
+ observer.next(this._value);
1985
1987
  return super.subscribe(observer);
1986
1988
  }
1987
1989
  };