/
foo.coffee
44 lines (33 loc) · 962 Bytes
/
foo.coffee
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
42
43
44
Stateful = require '../src/stateful'
class Foo extends Stateful
@state "EMPTY",
transitions:
initial: true
enter: "FULL"
exit: "FULL"
methods:
doTest: (num) ->
num = num * 10
console.log "num is #{num}"
console.log "common code is #{@testCommon()}"
@state "FULL",
transitions:
enter: "EMPTY"
exit: "EMPTY"
methods:
doTest: (num) ->
num = num * 3
console.log "num is #{num}"
console.log "common code is #{@testCommon()}"
@buildStateChart()
doTest: -> console.log "should not get called. maybe if super is called?"
testCommon: -> return "class Foo has two states: 'EMPTY' and 'FULL' we're currently in #{@state}"
foo = new Foo
foo.on "stateChange", (from, to) -> console.log "state was #{from}, state is #{to}"
console.log "foo.state is #{foo.state}"
val = 5
console.log "running foo.doTest with value: #{val}"
foo.doTest val
foo.state = "FULL"
foo.doTest val
console.log "all done"