-
Notifications
You must be signed in to change notification settings - Fork 99
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
Generator functions #35
Comments
Yes, and I really want to get this supported! If you or anyone coming across this wants to try implementing it in Greenlet, I'd be delighted to work with you to get it merged. |
I'd be happy to take a swing at this. I assume it will always return an instance of a |
Whoops, sorry for the slow reply! Yes this would coerce the main thread to an async generator, regardless of whether it is synchronous or asynchronous. |
fixes developit#35 tldr; Mainly wrapped the existing promise api to get it to work with async generators. I took atleast two iterations to get to this point. At first I thought to do the job with a readable Stream implementing async iterable on the main thread, but then was afraid of inconsistencies that would arise between the two apis. For example Readable Stream when finished will only return `{ done: true, value: undefined }` whereas async iterables can return `{ done: true, value: any }` when `any` is any value. So, then I decided to make a async generator that could talk to the worker for better compatibility. One thing to note is that the worker data onmessage receives an extra piece for the status to cause the iterator to use. This is similar to the Promise status, but for generators.
@Ayc0 @DCtheTall @developit hey, I made an attempt at this. Feel free to review. Hope you don't mind I took a shot at it 😅. I just was thinking about how useful this could be, and I also wanted to try and use it in a project, so I was hoping it would come sooner rather than later! |
Is it possible to support generator functions in addition to async functions?
The text was updated successfully, but these errors were encountered: