Simplification of Observable API
Okay, I'm going to throw my hat back in and see if I can resurrect this a little. What I'm going to propose is slightly different than the current proposal and different than RxJS, but I strongly feel it will work. ### API ```ts interface Observable<T> { new ( initialization: ( nextHandler: (value: T) => void, errorHandler: (err: any) => void, completeHandler: () => void, signal: AbortSignal ) => void; ): Observable<T> subscribe( nextHandler?: (value: T) => void, errorHandler?: (err: any) => void, completeHandler?: () => void, signal?: AbortSignal ): void; forEach(nextHandler: (value: T) => void, signal: AbortSignal): Promise<void> first(signal: AbortSignal): Promise<T>; last(signal: AbortSignal): Promise<T>; } ``` The idea is to remove the need to define `Observer` and `Subscriber`, as in other Observable implementations, and use simple functions instead. Also using a cancellation token (ala AbortController/AbortSignal) instead of introducing a `Subscription` type. I realize that `AbortController` and `AbortSignal` are not a part of JavaScript proper. However, I strongly feel JavaScript could use a cancellation primitive, and Observable, which is also a primitive, is not as useful without it. ### Defining an observable instance Below is the simplest use case for an observable. A synchronous set of values. ```ts test("should at least work", () => { const source = new Observable((next, e
Posted by benlesh on Oct 14, 2019, 3:44 PM
Tags
Related issues
- 2026 - Microsoft Office 365
- [Ubuntu] `ubuntu-latest` label will use Ubuntu 26.04 in November 2026
- Gamut mapping
- [Codex Desktop] Editing and resending a queued message triggers "App-server queued follow-up no longer exists"
- [Windows] ChatGPT 26.820.60940 fails with "invalid transport in mcp_servers.codex_app"; Beta 26.727.40816 works
- [BUG]: infinite loading of videos
Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments
github (SaaS)
2026 - Microsoft Office 365
[Ubuntu] `ubuntu-latest` label will use Ubuntu 26.04 in November 2026
Gamut mapping
[Codex Desktop] Editing and resending a queued message triggers "App-server queued follow-up no longer exists"
[Windows] ChatGPT 26.820.60940 fails with "invalid transport in mcp_servers.codex_app"; Beta 26.727.40816 works
[BUG]: infinite loading of videos
Restore GPT-5.6 Sol’s 372k Codex context window, or provide an opt-in setting
Codex Desktop for macOS repeatedly triggers `syspolicyd` / `trustd` CPU and memory runaway
Simplification of Observable API
Okay, I'm going to throw my hat back in and see if I can resurrect this a little. What I'm going to propose is slightly different than the current proposal and different than RxJS, but I strongly feel it will work. ### API ```ts interface Observable<T> { new ( initialization: ( nextHandler: (value: T) => void, errorHandler: (err: any) => void, completeHandler: () => void, signal: AbortSignal ) => void; ): Observable<T> subscribe( nextHandler?: (value: T) => void, errorHandler?: (err: any) => void, completeHandler?: () => void, signal?: AbortSignal ): void; forEach(nextHandler: (value: T) => void, signal: AbortSignal): Promise<void> first(signal: AbortSignal): Promise<T>; last(signal: AbortSignal): Promise<T>; } ``` The idea is to remove the need to define `Observer` and `Subscriber`, as in other Observable implementations, and use simple functions instead. Also using a cancellation token (ala AbortController/AbortSignal) instead of introducing a `Subscription` type. I realize that `AbortController` and `AbortSignal` are not a part of JavaScript proper. However, I strongly feel JavaScript could use a cancellation primitive, and Observable, which is also a primitive, is not as useful without it. ### Defining an observable instance Below is the simplest use case for an observable. A synchronous set of values. ```ts test("should at least work", () => { const source = new Observable((next, e
Comments (0)
No comments yet. Start the discussion.