- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.3k
 
[core] Async iterator #5403
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
base: main
Are you sure you want to change the base?
[core] Async iterator #5403
Conversation
          🦋 Changeset detectedLatest commit: b2672fa The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
 Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR  | 
    
| // Yield the initial snapshot if the actor is already running | ||
| if (this._processingStatus === ProcessingStatus.Running) { | ||
| yield this.getSnapshot(); | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this match the behavior of vanilla actorRef.subscribe?
| } | ||
| 
               | 
          ||
| while (this._processingStatus !== ProcessingStatus.Stopped) { | ||
| yield await new Promise<SnapshotFrom<TLogic>>((resolve, reject) => { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is neat but I think we should do better in the library context. This resubscribes with each iteration step. It would be better to maintain a single subscription throughout the full lifecycle of the iteration.
| expect(snapshots[2].status).toBe('done'); | ||
| }); | ||
| 
               | 
          ||
| it('should handle errors in async iteration', async () => { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't test what it claims - this just happens to use events and states named with "error" but in reality this machine completes gracefully through a regular final state
Co-authored-by: Mateusz Burzyński <[email protected]>
Make actors async iterable: