咨询:RxJS的Observables未来是否会成为JavaScript核心API?
Great question—this is something a lot of developers working with reactive streams have wondered about. Let’s break down the current state and future possibilities clearly:
Current Status
Right now, Observables are not part of JavaScript’s core API. RxJS remains a widely adopted third-party library that implements the Observable pattern, but there’s no native support in browsers or Node.js for its exact interface.
Past TC39 Proposal Context
A few years back, there was a TC39 proposal to add a native Observable type to JavaScript. It made it to Stage 1 (the formal proposal stage) but eventually stalled and never progressed to Stage 4—the final step required for inclusion in the ECMAScript standard. Key reasons for this stall included:
- Overlap with existing native tools: JavaScript already has
Promise,async/await, andReadableStreamfor handling asynchronous operations. TC39 members debated whether adding another reactive primitive was truly necessary. - API complexity: The full RxJS-style Observable interface (with operators like
map,filter,switchMap) is extensive. Standardizing it would require balancing competing needs from different community groups, which proved challenging. - Lack of urgent community demand: While RxJS is popular in frameworks like Angular, most developers can solve asynchronous problems with existing native APIs, so the push for a core Observable wasn’t strong enough to keep the proposal moving.
Future Possibilities
It’s not impossible that Observables could eventually make their way into the core, but it’s unlikely in the near term. For this to happen:
- There would need to be a clear, unmet need that existing native APIs can’t address (e.g., more streamlined handling of complex multi-source asynchronous streams).
- The TC39 committee would need to revisit the proposal, possibly with a simplified scope focused on the core Observable type rather than the full suite of operators.
- The broader JavaScript community would need to rally behind the proposal to show widespread support.
What You Can Do Now
If you rely on Observables, using RxJS (or similar libraries like xstream) is still the most robust approach. Alternatively, you can use native APIs like AsyncIterator or ReadableStream for simpler stream-based tasks, though they don’t offer the same rich operator set as RxJS.
内容的提问来源于stack exchange,提问作者Willem van der Veen

