Comments (4)
Could you share and code snippet example with what you want to achieve?
from stateless.
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 stateless.
From the example of https://pkg.go.dev/reflect#TypeOf you can then actually check if a type implements an interace:
mport (
"fmt"
"io"
"os"
"reflect"
)
func main() {
// As interface types are only used for static typing, a
// common idiom to find the reflection Type for an interface
// type Foo is to use a *Foo value.
writerType := reflect.TypeOf((*io.Writer)(nil)).Elem()
fileType := reflect.TypeOf((*os.File)(nil))
fmt.Println(fileType.Implements(writerType))
}
from stateless.
Implemented in #46
from stateless.
Related Issues (20)
- stateless.GetTransition can panic HOT 1
- Invalid DOT graph generated when methods are used as actions HOT 1
- README does not explain where and how states are defined HOT 1
- What are internal transitions? HOT 3
- No way to get error returned from PermitDynamic HOT 1
- A better way to pass transition arguments HOT 3
- unaligned 64-bit atomic operation HOT 4
- Support for extended states HOT 3
- Export to DOT graph doesn't produce correct string representation of the state machine HOT 2
- How to get the super state of hierarchical state? HOT 4
- Concurrent issue on String() function HOT 1
- No valid leaving transitions are permitted from state ... for trigger ... HOT 1
- Optimizing findHandler HOT 3
- Does FiringQueued statemachine run to complete if any error occurs?
- How to get superstate of source/destination state in OnTransitioned
- Allow setting a state machine to some intermediate state HOT 2
- Allow adding actions for leaving a state with a specific trigger HOT 2
- How to stop FSM execution
- How to trigger state machine with external storage into sub init state?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stateless.