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

Create initial reference implementation #42

Closed
wants to merge 11 commits into from
Closed

Conversation

benlesh
Copy link
Collaborator

@benlesh benlesh commented Aug 1, 2023

Just a spike in TypeScript. Will add tests in a followup, add compilation to JavaScript, etc.

@benlesh
Copy link
Collaborator Author

benlesh commented Aug 1, 2023

Could even just convert it to JavaScript. I'm relatively indifferent.

@domfarolino
Copy link
Collaborator

Could even just convert it to JavaScript. I'm relatively indifferent.

Finally getting to this! This is looking quite good, however I think I would prefer the reference implementation to be in pure JS if that's alright?

impl/observable.ts Outdated Show resolved Hide resolved
benlesh and others added 5 commits November 29, 2023 13:35
Just a spike in TypeScript. Will add tests in a followup, add compilation to JavaScript, etc.
- moves license to LICENSE.txt
- Updates reference impl to reflect proposed changes so far
- Adds catch, finally, do, and switchMap
@benlesh
Copy link
Collaborator Author

benlesh commented Dec 11, 2023

@domfarolino should we merge this? is it useful?

@domfarolino
Copy link
Collaborator

See #42 (comment).

LICENSE.txt Outdated Show resolved Hide resolved
eventType: K,
): Observable<AbstractWorkerEventMap[K]>;
}
interface Animation {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all of these being added?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly? Just to be nice. If anyone wants to use this with TypeScript, these types will help them. They don't need to be here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My two cents is we leave them. They can't do anything but help folks use this and try it out.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm just not sure what they're actually doing. Can you help me understand what they add?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They map the event name strings to the event subclasses. This way eventTarget.on('click') will typed as an Observable<MouseEvent> while eventTarget.on('keypress') will be typed as an Observable<KeyboardEvent>.

interfaces.txt Outdated Show resolved Hide resolved
});
}
reduce(reducer, initialValue, options) {
return new Promise((resolve, reject) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we ever call reject here if signal gets aborted? I got here because I am spec'ing and implementing toArray(), and I was looking to find the semantics of what happens to the returned Promise when options.signal is aborted, but couldn't find it.

We certainly reject() in the error handling case specifically, but aborting options.signal shouldn't result in error actually being invoked (I think).

eventType: K,
): Observable<AbstractWorkerEventMap[K]>;
}
interface Animation {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm just not sure what they're actually doing. Can you help me understand what they add?

}
}
if (errors) {
// TODO: We need to figure out how to report multiple errors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bug against the repo would be great to track this. I'm not sure I understand what this represents as-is, but some elaboration would help us solve it in the open I imagine. Alternatively, can't we just report each error individually? That's what the spec and impl does right now:

We should probably write a WPT for this case though.

return this.#signal;
}
get isActive() {
return this.#active && !this.signal.aborted;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to align to the current spec. AFAICT it's possible to see isActive === false while also this.signal.aborted === false.

...partialObserver,
};
const subscriber = new Subscriber(options?.signal, observer);
this.start(subscriber);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to try/catch?

@domfarolino
Copy link
Collaborator

This PR really hasn't seen any activity in months, and with Chromium getting pretty close to shipping Observables, I feel like we should probably just close this PR out. But feel free to re-open if you have plans to get to it.

@domfarolino domfarolino closed this Apr 3, 2024
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

Successfully merging this pull request may close these issues.

6 participants