-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add Single, Maybe and Completable #2469
Comments
No, it's not planned. It is not a goal of v5 to create full-compliant operator set to other languge bindings or even v4, and there are some added opeator or dropped operator between. Once there is suffecient usecase and demand it can be obviously discussed in further. |
I'm also not sure I would look to RxJava for inspiration. Java is severely lacking in expressive power, even with its recent editions. JavaScript has long had better expressiveness as have most other languages. |
Just want to make sure this issue didn't got closed accidentally. It's not about new operators. It's about other base classes besides
|
@passsy yes, while attached references are saying only about |
If y'all are open to a bit of discussion on the topic, I do think there are use cases for a type analogous to RxJava's
That said, the workaround isn't too bad right now, one can (assuming the stream is hot) filter all of the values (e.g. Example use caseIn a redux-observable epic, if you want to dispatch an event after some chain of other actions. A bit of setup using the example they have on their website: const PING = 'PING';
const PONG = 'PONG';
const ping = () => ({ type: PING });
const pingEpic = action$ =>
action$.ofType(PING)
.delay(1000)
.mapTo({ type: 'PONG' });
const pingReducer = (state = { isPinging: false }, action) => {
switch (action.type) {
case 'PING':
return { isPinging: true };
case 'PONG':
return { isPinging: false };
default:
return state;
}
}; Now if you wanted to dispatch an action after const START_ROUND_TRIPS = 'START_ROUND_TRIPS';
const END_ROUND_TRIPS = 'END_ROUND_TRIPS';
const endRoundTrip = (count) => ({type: END_ROUND_TRIPS, payload: {count}})
const roundTripEpic = action$ =>
action$.ofType(START_ROUND_TRIPS)
.concatMap((action) => Observable.concat(
Completable.from(action$.ofType(PONG).take(action.payload.count)), // Up for discussion
Observable.of(endRoundTrip(action.payload.count))
)) It's important that the inner observable not actually contain the |
(I had forgotten about
Some combination of those work as a replacement for a hypothetical |
From a pure technical point of view one might argue that a completeable is unnecessary since an observable can be used for the job. |
You can simple create the objects in next releases, is useful to have them for some cases and also makes the code more readable (knowing for what a Completeable, Single and a Maybe are for) |
@trxcllnt Just wanted to point out something. Yes, all of this is possible with combinations of |
Would it be possible to revisit this? I think @WowMuchName makes some compelling points. Personally I have found that using Observables as Singles, while technically possible, creates ambiguity and leads to bugs. |
+1 on this, Single/Maybe and Completable make it more understandable and maintainable by explicitly saying what behavior you'll have. Having just Observable is for me as bad as saying Any on return type of a method, you don't know what you'll have except if you actually look the implementation... |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
RxJava 2 has the concept of
Single
,Maybe
andCompletable
. They got quickly adopted by RxSwift 3.3.0.I couldn't find anything about those reactive types in rxjs. Are they planned?
The text was updated successfully, but these errors were encountered: