为何JavaScript中的Observable未被命名为EventStream?
Great question—this terminology confusion is super common, especially since so many resources use "event streams" as an intuitive analogy for Observables. Let's unpack why the name Observable was chosen over EventStream:
First, let's acknowledge what you've noticed: many educators (like the one who tried framing them as "async collections" or "collections arriving over time" but still defaulted to "streams", and the author of that popular reactive programming intro that called them "event streams") use stream-based language because it's easier for beginners to wrap their heads around data unfolding over time. But there are critical reasons the formal name is Observable:
Observables are more than just events: Event streams imply a focus on discrete events (like button clicks, API responses), but Observables are designed to represent any sequence of values over time—this includes events, but also continuous data (like sensor readings), deferred computations, or even synchronous value sequences. The name emphasizes their general-purpose nature, not just event handling.
Ties to the Observer Design Pattern: The name comes directly from the classic Observer Pattern, where an observable object notifies observers of state changes. Reactive libraries like Rx extended this pattern to handle sequences over time, so using "Observable" connects the concept to established software engineering principles, making it easier for developers familiar with the pattern to adapt.
Ecosystem standardization: Early reactive libraries had varied terminology (Bacon.js used EventStream, for example), but Rx (Reactive Extensions) became the cross-platform standard (with implementations in C#, Java, JavaScript, etc.). As Rx gained traction, "Observable" became the de facto term to keep consistency across languages and frameworks.
Avoiding "stream" overload: The word "stream" is already used in countless contexts—Node.js I/O streams, file streams, etc.—each with their own specific behaviors. Using Observable helps clearly distinguish this reactive programming concept from other stream types that don't support the same operators (like
map,filter) or flexible value emission.
At the end of the day, "event stream" is a great teaching analogy, but "Observable" captures the full breadth and intent of the concept better.
内容的提问来源于stack exchange,提问作者Magne

