nickuraltsev / finity Goto Github PK
View Code? Open in Web Editor NEWA finite state machine library for Node.js and the browser with a friendly configuration DSL.
License: MIT License
A finite state machine library for Node.js and the browser with a friendly configuration DSL.
License: MIT License
Branch | Build failing 🚨 |
---|---|
Dependency | cross-env |
Current Version | 3.1.4 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As cross-env is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
<a name"3.2.0">
The new version differs by 4 commits .
dad00c4
feat(revamp): revamp the entire lib (backward compatible) (#63)
e33a85c
docs(README): Add doc for cross-var. (#58)
5e590ec
docs(README): added how to use cross-env to run npm sub-scripts (#53)
afdb2de
docs(README): mention Bash on Windows (#49)
See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
I have to build a map of State machines and in case the node server goes down, I need to resurrect them all later in the exact states they were when the server is restarted. Any idea how this can be implemented.
Any way I can restore the FSMs by storing them into Mongo/Redis.
basically, I need a constructor or setStateMachine() fn
hello there 👋
first of all, i just wanted to express my gratitude for this project. i think the API is great, the code is readable/understandable, and the functionality is complete and robust.
i'm using this package in a TypeScript project. I need to do something like the following, but TypeScript is giving me the error shown:
if (stateMachine.getCurrentState() === 'some_state' &&
stateMachine.getStateHeirarchy !== undefined && stateMachine.getStateHeirarchy()[1] === 'some_substate') {
// do stuff
}
TypeScript error:
[ts] Property 'getStateHierarchy' does not exist on type 'StateMachine<string, string>'.
the simplest fix i could think of would just be to export the interface for HierarchicalStateMachine
so that after the stateMachine.getStateHeirarchy !== undefined
condition, i could cast my stateMachine
to that type specifically. i don't know if there's a more advanced technique for expressing true polymorphism in TypeScript.
edit: on closer inspection, it looks like the StateMachineConfigurator.start()
method always returns a HierarchicalStateMachine
, so maybe its just a matter of replacing the StateMachine
type with the former in the definitions.
thanks!
Hello,
I desperately needed a graphical representation of the state machine I have configured. So I wrote this function to return a string representing the configured state machine in graphviz dot language. Feel free to extend and include in your code.
Ognian
When i try to handle events that are not configured, that is canHandle('e) returns false, It would be great if we could specify an "else" event which gets fired.
It could be used something like this:
var fsm = finity.configure()
.initialState('start')
.on('a').transitionTo('Pass')
.on('_').transitionTo('Fail');
I think this would be really good feature to have.
Not sure what's going on, but with node 0.12.14 this blows up:
My configuration:
this._queueStates = StateMachine
.configure()
.initialState('idle')
.onEnter(() => {
if (this._queue.length > 0) this._queueStates.handle('enqueue');
})
.on('enqueue').transitionTo('process')
.state('process')
.onEnter(() => {
this._processNextQueuedJob()
})
.on('idle').transitionTo('idle')
.global()
.onStateEnter((state: string) => this._log.info(`QUEUE: Entering state ${state}`))
.onUnhandledEvent((event: string, state: string) => this._log.info(`QUEUE: Unhandled event '${event}' in state '${state}.'`))
.start();
Then I enqueue something and tell the SM to "enqueue":
this._queue.push(qj);
this._queueStates.handle('enqueue');
and BOOM!
TypeError: undefined is not a function
at StateMachine.selectTransition (XYZ\node_modules\finity\lib\core\StateMachine.js:304:26)
at StateMachine.getTransitionForEvent (XYZ\node_modules\finity\lib\core\StateMachine.js:149:61)
at StateMachine.processEvent (XYZ\node_modules\finity\lib\core\StateMachine.js:121:35)
at XYZ\node_modules\finity\lib\core\StateMachine.js:83:25
at StateMachine.execute (XYZ\node_modules\finity\lib\core\StateMachine.js:98:9)
at StateMachine.handle (XYZ\node_modules\finity\lib\core\StateMachine.js:82:14)
at AdobeMediaEncoder.enqueueJob (XYZ\src\ame.ts:708:27)
at XYZ\testing\test-ame.js:54:26
at _fulfilled (XYZ\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (XYZ\node_modules\q\q.js:863:30)
Works fine in Node 4.4.5
(Just switching versions using nodist)
Apprently this is within selectTransition() where the "transitions" object is JSON.stringify(transitions) -> "[{"targetState":"process","isInternal":false,"actions":[],"condition":null}]"
which does not have any find() method so this blows up trying to call "undefined";
return transitions.find(function (t) {
return !t.condition || t.condition(context);
});
(And why am I using 0.12.14? Well.. long story)
4.26.1
to 4.27.0
.This version is covered by your current version range and after updating it in your project the build failed.
webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
getResolve
method to create their own resolver function with custom optionsexport * from
The new version differs by 12 commits.
f47bf8b
4.27.0
a67ffcd
Merge pull request #8452 from webpack/feature/resolveWithOptions
96f625c
Merge pull request #8457 from webpack/bugfix/rebuild-provided-exports
56feccc
convert test case to normal function for node.js 6 support
2f4296e
fix a bug which causes incorrect providedExports for cached modules
f944002
Merge pull request #8451 from webpack/bugfix/split-chunks
162da1c
add getResolve method to loader context
3b46b48
enforce doesn't affect minSize for maxSize
72a8a1f
Merge pull request #8440 from Connormiha/oprimize-chunk-can-be-integrated
537d3e4
Cache hasRunstime in chunk
e3e8a68
Merge pull request #8405 from xiaoxiaojx/fix-function-plugin-apply
70b9a1b
fix parameter missing when plugin type is a funtion
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
I'm using finity with react and I need to stop the FSM when a component will be unmounted.
I figured a few ways to call the internal stop() method but they seem a bit hacky. Could we expose the stop() method, the same way start() is available?
Or do I need a custom "stop" event and handle it that way?
const worker = Finity
.configure()
.initialState('ready')
.on('task_submitted').transitionTo('running')
.state('running')
// here I have the context.eventPayload
// but if I want to inside the worker gerate a data to use in another state?
.do((state, context) => processTaskAsync(context.eventPayload))
.onSuccess().transitionTo('succeeded')
.onFailure().transitionTo('failed')
.onTimeout(1000)
.transitionTo('timed_out')
.global()
.onStateEnter(state => console.log(`Entering state '${state}'`))
.start();
I'm trying to execute code from the example:
const config = Finity
.configure()
.initialState('state1')
.getConfig();
const firstInstance = Finity.start(config);
const secondInstance = Finity.start(config);
The result is an error:
Finity.min.js:1 Uncaught Error: Initial state must be specified.
Hi, thanks for the great module.
I have a lot of workers and when an event happens I would like to know which worker trigger this event.
let config = Finity.configure()
.initialState('stop')
.global()
.onStateEnter((state, context) =>
console.log(`Entering state '${state}'`)
// which worker is handling this event?
)
.getConfig()
let worker0 = Finity.start(config)
let worker1 = Finity.start(config)
Branch | Build failing 🚨 |
---|---|
Dependency | babel-eslint |
Current Version | 8.1.2 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
babel-eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 4 commits.
ef27670
8.2.0
eba5920
Add other parser plugins, update yarn.lock (#569)
e201fb4
Make 2018 the default ecmaVersion for rules relying on parserOptions (#556)
1dedd1b
update babel packages (#565)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.