mus
v0.0.4
Published
RePractise DSL with TypeScript
Downloads
2
Readme
Mus - FSM in TypeScript
finite-state machine in TypeScript for Angular
Goal
- basic state
- annotation support
Draft
- Annotation
@transition(field='state', source='new', target='published', conditions=[can_publish])
- Simple DSL Support
@transition(
field='state',
source='for_moderators',
target=GET_STATE(
lambda self, allowed: 'published' if allowed else 'rejected',
states=['published', 'rejected']))
- Self Usage
e.x. Transit Status
- beginTransit
- endTransit
- failTransit
- doTransit
References
- https://github.com/jakesgordon/javascript-state-machine
- https://github.com/eonarheim/TypeState
- https://github.com/kmmbvnr/django-fsm
- https://github.com/hekailiang/squirrel
JavaScript Example:
var fsm = new StateMachine({
init: 'solid',
transitions: [
{ name: 'melt', from: 'solid', to: 'liquid' },
{ name: 'freeze', from: 'liquid', to: 'solid' },
{ name: 'vaporize', from: 'liquid', to: 'gas' },
{ name: 'condense', from: 'gas', to: 'liquid' }
],
methods: {
onMelt: function() { console.log('I melted') },
onFreeze: function() { console.log('I froze') },
onVaporize: function() { console.log('I vaporized') },
onCondense: function() { console.log('I condensed') }
}
});
License
@ 2018 A Phodal Huang's Idea. This code is distributed under the MIT license. See LICENSE
in this directory.