Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion goldens/public-api/core/rxjs-interop/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export interface ToSignalOptions<T> {
initialValue?: unknown;
injector?: Injector;
manualCleanup?: boolean;
rejectErrors?: boolean;
requireSync?: boolean;
}

Expand Down
15 changes: 0 additions & 15 deletions packages/core/rxjs-interop/src/to_signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ export interface ToSignalOptions<T> {
*/
manualCleanup?: boolean;

/**
* Whether `toSignal` should throw errors from the Observable error channel back to RxJS, where
* they'll be processed as uncaught exceptions.
*
* In practice, this means that the signal returned by `toSignal` will keep returning the last
* good value forever, as Observables which error produce no further values. This option emulates
* the behavior of the `async` pipe.
*/
rejectErrors?: boolean;

/**
* A comparison function which defines equality for values emitted by the observable.
*
Expand Down Expand Up @@ -172,11 +162,6 @@ export function toSignal<T, U = undefined>(
const sub = source.subscribe({
next: (value) => state.set({kind: StateKind.Value, value}),
error: (error) => {
if (options?.rejectErrors) {
// Kick the error back to RxJS. It will be caught and rethrown in a macrotask, which causes
// the error to end up as an uncaught exception.
throw error;
}
state.set({kind: StateKind.Error, error});
},
// Completion of the Observable is meaningless to the signal. Signals don't have a concept of
Expand Down
22 changes: 0 additions & 22 deletions packages/core/rxjs-interop/test/to_signal_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,6 @@ describe('toSignal()', () => {
);
});

it('should throw the error back to RxJS if rejectErrors is set', () => {
let capturedObserver: Observer<number> = null!;
const fake$ = {
subscribe(observer: Observer<number>): Unsubscribable {
capturedObserver = observer;
return {unsubscribe(): void {}};
},
} as Subscribable<number>;

const s = toSignal(fake$, {initialValue: 0, rejectErrors: true, manualCleanup: true});
expect(s()).toBe(0);
if (capturedObserver === null) {
return fail('Observer not captured as expected.');
}

capturedObserver.next(1);
expect(s()).toBe(1);

expect(() => capturedObserver.error('test')).toThrow('test');
expect(s()).toBe(1);
});

describe('with no initial value', () => {
it(
'should return `undefined` if read before a value is emitted',
Expand Down