Conversation
Updated example/main.go to use the simpler machine.GetStateChan() pattern instead of manually setting up broadcast.Manager and registering hooks. This aligns the example with the "Simple Method (Recommended)" approach documented in the README, making it easier for users to understand and follow best practices. Changes: - Removed manual broadcast.Manager creation - Removed manual hook registration for broadcasting - Use machine.GetStateChan(ctx, stateChan) directly - Removed unused broadcast package import The example now demonstrates the recommended approach for 90% of use cases, while advanced users can still refer to documentation for the manual broadcast.Manager pattern when needed.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
When using machine.GetStateChan() with a user-created channel, the broadcast manager does not close the channel on context cancellation (since it's an external channel). This caused the goroutine to hang waiting for the channel to close. Updated the goroutine to watch for context cancellation using a select statement, ensuring proper cleanup when the context is done. This fixes the test deadlock in TestRun.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Updated example/main.go to use the simpler machine.GetStateChan() pattern instead of manually setting up broadcast.Manager and registering hooks.
This aligns the example with the "Simple Method (Recommended)" approach documented in the README, making it easier for users to understand and follow best practices.
Changes:
The example now demonstrates the recommended approach for 90% of use cases, while advanced users can still refer to documentation for the manual broadcast.Manager pattern when needed.