Skip to content
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

observableCompleted operator #5538

Closed
joshribakoff opened this issue Jun 27, 2020 · 4 comments
Closed

observableCompleted operator #5538

joshribakoff opened this issue Jun 27, 2020 · 4 comments

Comments

@joshribakoff
Copy link
Contributor

joshribakoff commented Jun 27, 2020

Feature Request

Adding a observableCompleted operator

Is your feature request related to a problem? Please describe.

This is useful for unit testing a stream that ends with .repeat(). Eg. in redux-observable:

const epic = (a$, s$) => a$.pipe(
  ofType('foo'),
  switchMap(...),
  doStuff(...),
  takeUntil(...),
  repeat(),
  takeUntil(observableCompleted(a$))
)

Describe the solution you'd like
I'd like to contribute an operator that takes a notifier observable as an argument, and when that notifier completes, the operator emits.

Describe alternatives you've considered

It could go to a third party repo like https://github.com/cartant/rxjs-etc/ but it feels more "core" to me...

(If this is new operator request) describe reason it should be core operator

The operator could live anywhere, but it seems pretty core to me to be able to change nexts to completions & vice versa, not sure if there is another way to do this now?

@joshribakoff joshribakoff changed the title observableCompleted observableCompleted operator Jun 27, 2020
@cartant
Copy link
Collaborator

cartant commented Jun 27, 2020

The implementation would be trivial: https://github.com/cartant/rxjs-etc/blob/main/source/operators/hasCompleted.ts

IMO, the core would become bloated if easily-derived operators - or observables - like this were to be added.

@joshribakoff
Copy link
Contributor Author

It was not trivial to me, at all. Especially not your elegant solution, I had come up with something far uglier, and only after hours of struggling. Lack of certain affordances in RxJs have made RxJs very difficult to adopt for me, because what were in my eyes key building blocks were missing from the core.

I actually didn't notice that rxjs-etc already has it. I personally do not think the operators being bloated are the issues with RxJs, it's more like lack of "real world" examples, but people just say "there are too many operators". I actually think having more operators (with more real world & visual examples) will make RxJs more approachable.

As it stands today, there are operators that are equally as "easily" derived, which I could go cherry pick...

Maybe this issue could be reframed to give more visibility to the 3rd party offerings?

FWIW, I think converting from "next" to "completed" & vice versa is one of those things that's really important for people to grok, and its not right now. It's like those algorithm challenges where you validate a tree, or check if its symmetrical. It teaches you to think about how to control the computer. Having "easily derived" operators teaches people who may not be as smart, like me, so they can derive them by "borrowing" ideas from smarter people like yourself. It would be great to get more visibility, if not hoisting the operator to the core, perhaps more docs about doing these kinds of operations yourself, or links to 3rd party libs like yours would be great :)

@cartant
Copy link
Collaborator

cartant commented Jun 28, 2020

Maybe this issue could be reframed to give more visibility to the 3rd party offerings?

https://ncjamieson.com/rxjs-community-packages/

@cartant cartant closed this as completed Jun 28, 2020
@joshribakoff
Copy link
Contributor Author

A post on your personal blog does not solve the visibility problem with the main docs glossing over a lot of important concepts / operators, which makes rxjs hard to approach. Most likely people will give up & continue to program imperatively instead of searching for your blog post.

joshribakoff added a commit to joshribakoff/rxjs that referenced this issue Jun 28, 2020
Continuing the discussion from ReactiveX#5538 which was closed, I feel like there is a fragmentation problem where important context for making good use of RxJs is missing from the docs. This attempts to bridge the gap, and implements the suggestion I was trying to discuss before 5538 was abruptly closed, it takes a step in the right direction by making these 3rd party packages actually visible, so readers of the docs are actually aware there is more to the ecosystem than just what is shown on the official docs.
benlesh pushed a commit that referenced this issue Jun 29, 2020
Continuing the discussion from #5538 which was closed, I feel like there is a fragmentation problem where important context for making good use of RxJs is missing from the docs. This attempts to bridge the gap, and implements the suggestion I was trying to discuss before 5538 was abruptly closed, it takes a step in the right direction by making these 3rd party packages actually visible, so readers of the docs are actually aware there is more to the ecosystem than just what is shown on the official docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants