-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is Observable
the right name?
#31
Comments
Naming
Firmly, yes. This is the name for this exact type across dozens of popular languages (JavaScript, C#, Python, C++, Swift, Kotlin, Java, Ruby, etc, etc). As a defined primitive, it's the name for the type. Very well known and understood. It could be argued that the interface is a "Subscribable" or something like that... but the type itself is idiomatically called an "Observable" across millions and millions of lines of code in many languages. Observable as a "dual" of Iterable
They would argue correctly. At least in the case of We start with Iterable/Iterator(I'm using a generic non-JS iterable/iterator pattern below, since JS is pretty avante garde in how iteration works, allocating an object every turn and having a possible "yes I'm done and here's a value" state that is generally ignored in most means of consumption) interface Iterator<T> {
hasNext(): boolean;
next(): T;
}
interface Iterable<T> {
iterator(): Iterator<T>
} We then push where we were pulling before:interface Observer<T> {
hasNext(notDone: boolean): void;
next(value: T): void;
}
interface Observable<T> {
observer(observer: Observer<T>): void;
} We fix the negative
|
Given the really superb explanation here by @benlesh (thanks!) and the fact that if we're being honest, we're probably unlikely to re-litigate the name of this fairly well-known interface, I think I'll close now, especially since we have the reasoning all documented here for other people to see in the future here. |
Now this is a kind of crazy question maybe but thought I'd ask it, I understand Observable is a very common name in the community right now - but is it the right one?
Iterable, Thenable, Iterator, generator - these are all protocols or interfaces. It could be argued, or mistaken by a newcomer, that Observable fits into this category - a protocol or interface that allows something to be "observed".
The text was updated successfully, but these errors were encountered: