-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.js
More file actions
33 lines (33 loc) · 864 Bytes
/
command.js
File metadata and controls
33 lines (33 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(function(App){
let Command=function(data){
this.Data=data
this.ContextKey="Data"
this.Transitions=[]
this.Final=""
this.Fail=""
this.ID=this.CommandID
}
Command.prototype.CommandID=""
Command.prototype.WithData=function(data){
this.Data=data
return this
}
Command.prototype.WithFinalState=function(final){
this.Final=final
return this
}
Command.prototype.WithFailState=function(fail){
this.Fail=fail
return this
}
Command.prototype.ApplyData=function(automaton){
automaton.WithData(this.ContextKey,this.Data)
}
Command.prototype.Push=function(){
let a=App.Push(this.Transitions,this.Final)
a.WithFailState(this.Fail)
this.ApplyData(a)
return this
}
return Command
})(App)