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

Should add the checking subscriber's active state to the first step of next(value)/error(error)/complete() methods? #114

Open
tetsuharuohzeki opened this issue Feb 10, 2024 · 3 comments · May be fixed by #129

Comments

@tetsuharuohzeki
Copy link

These supporting concepts does not check subscriber's active state.

And they use as null checking for each of next/error/complete algorithm instead of checking active concept, because of close a subscription concept set active to false and set next/error/complete algorithm to null.

However, I feel it's an implicit steps. I also think it's better to use active concept and checking it at the first step of each of subscriber's next(value) / error(error) / complete() concepts.

@domfarolino
Copy link
Collaborator

Checking algorithm step null-ness vs checking active is not equivalent, unfortunately. You can have a Subscriber whose algorithms are null (for example, if nobody provided a complete() handler) but is still active. So if Subscriber#complete() only checked active, it will try and execute the complete steps, which may be null.

Does that make sense?

@tetsuharuohzeki
Copy link
Author

@domfarolino

So if Subscriber#complete() only checked active, it will try and execute the complete steps, which may be null.

By subscribe to an Observable concept, the steps 2 lets a new internal observer and it will be used to initialize subscriber in the step 5.

https://wicg.github.io/observable/#observable-subscribe-to-an-observable

  1. Let internal observer be a new internal observer.

  1. Let subscriber be a new [Subscriber]> (https://wicg.github.io/observable/#subscriber), initialized as:

But internal observer has initial value but I read they does not means null:

https://wicg.github.io/observable/#internal-observer

An internal observer is a struct with the following items:
next steps
An algorithm that takes a single parameter of type any. Initially, these steps do nothing.
error steps
An algorithm that takes a single parameter of type any. Initially, the default > error algorithm.
complete steps
An algorithm with no parameters. Initially, these steps do nothing.

From these definitions of the current spec and other parts, I seem next/error/complete algorithm would not be null without steps in close a subscription concept.

@domfarolino
Copy link
Collaborator

From these definitions of the current spec and other parts, I seem next/error/complete algorithm would not be null without steps in close a subscription concept.

Looks like you're right, good catch! Feel free to send a PR my way to clean this up in the spec, if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants