-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathTransition.ts
More file actions
41 lines (33 loc) · 741 Bytes
/
Transition.ts
File metadata and controls
41 lines (33 loc) · 741 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
34
35
36
37
38
39
40
41
import State from "./State";
export interface Message {
event: string;
payload?: any;
}
/**
* A Transition is a link between two states.
* It fires whenever an state has an exit transition identified by `event`.
*/
export default class Transition {
from_: State;
to_: State;
event_: string;
constructor(from: State, to: State, event: string) {
this.event_ = event;
this.from_ = from;
this.to_ = to;
}
setup() {
this.from_.addExitTransition(this);
this.to_.addEnterTransition(this);
return this;
}
get from() {
return this.from_;
}
get to() {
return this.to_;
}
get event() {
return this.event_;
}
}