Skip to content

Commit

Permalink
added ability for default state to get passed in.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brec Carson committed Apr 13, 2012
1 parent 602ad80 commit 3f78049
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
11 changes: 9 additions & 2 deletions lib/statechart.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
@@ -1,14 +1,14 @@
{
"name" : "stateful"
,"description" : "Common stateful base class for both browser and NodeJS environments."
,"description" : "Common, stateful base class for both browser and NodeJS environments."
,"homepage" : "http://not-up-yet.com"
,"keywords" : ["statechart","events","server","client"]
,"author" : "brec-c"
,"engines" : {"node":"*"}
,"licenses" : [{"type":"MIT","url":"https://github.com/brec-c/stateful/blob/master/LICENSE"}]
,"repository" : {"type":"git", "url": "git://github.com/brec-c/stateful.git"}
,"main" : "index.js"
,"version" : "0.0.2"
,"version" : "0.0.3"
,"dependencies" : {
"coffee-script" : "~1.2.0"
,"common-emitter" : ""
Expand Down
9 changes: 6 additions & 3 deletions src/statechart.coffee
Expand Up @@ -33,11 +33,14 @@ class Stateful extends Emitter

# TODO: confirm integrity of chart, makes sure all entry / exit points are accounted for

constructor: (config) ->
constructor: (config={}) ->
return unless @statechart?

stateName = _.keys(@statechart)[0]
@setState @statechart[stateName]
if config.defaultState
@setState @pathResolver config.defaultState
else
stateName = _.keys(@statechart)[0]
@setState @statechart[stateName]

dispose: -> @removeAllListeners()

Expand Down

0 comments on commit 3f78049

Please sign in to comment.