-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
SetTriggerParameters enhancment: validate interfaces #45
Comments
Could you share and code snippet example with what you want to achieve? |
I have a few states where I want to pass an error through a transition errIntType := reflect.TypeOf((*error)(nil)).Elem()
sm.SetTriggerParameters(ActionReturnError, errIntType)
sm.Configure(StateFinished).
OnEntryFrom(ActionReturnError, func(ctx context.Context, args ...interface{}) error {
err := args[0].(error)
r := &VolunteerResult{
Err: err,
}
chResult <- r
close(chResult)
return nil
}) |
From the example of https://pkg.go.dev/reflect#TypeOf you can then actually check if a type implements an interace:
|
Implemented in #46 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently
SetTriggerParameters
only matches types exactly. It would be great if instead of requiring the exact type, you could passSetTriggerParameters
andvalidateParameters
used reflect.Value#Implements to validate the parameter.The text was updated successfully, but these errors were encountered: