Docs: wrong/misleading Marble Diagram for bufferToggle? #6995
UserGalileo
started this conversation in
Report issues other than bug
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi folks,
I was looking at the Marble Diagram for the
bufferToggle
operator here and if I'm not mistaken I think it's either wrong or at least misleading.EDIT: In fact I double checked the
windowToggle
operator which behaves pretty much the same and that one is in fact correctThe line representing the closing Observable (3rd line from above) is a straight line form start to end, like if it was subscribed only once, while in reality the closing Observable is recreated each time the opening Observable emits.
It'd be correct if the
closingSelector
was called only once but that's not the case, so it shouldn't be a continuous line.It's also "technically" correct if you imagine the closing Observable to be hot: in this case the results would be correct, but the fact that it's a continuous line doesn't make clear that the Observable is recreated each time. I think a cold Observable would be much more appropriate. I've been using RxJS for years and that diagram confused me so I very much expect beginners to struggle.
This is more or less how it should be imho (for convenience I make the closing notifier complete with the first emission), as you can see we have different results:
Forgive me, it's not easy to show with ascii marbles but I hope you get the idea :)
By the way, imho in cases like this one (I've seen it in other diagrams, too), that "incriminated" line makes it very hard to understand, even with my proposed solution. That's because the reader doesn't know, by looking at the diagram, that the notifier is recreated multiple times. I've had this feedback a lot of times with students for other operators too. Maybe we can think of another way to represent notifiers? Either by separating them or making them a separate opacity/color/idontknow. In this case I'd propose "linking" the line so that it starts with every emission from the opening Observer (and repeat, in this case 2 times).
Beta Was this translation helpful? Give feedback.
All reactions