Skip to content

Commit cccd978

Browse files
committed
updated README and RELEASE_NOTES
1 parent 8e1c71b commit cccd978

3 files changed

Lines changed: 43 additions & 57 deletions

File tree

README.md

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,23 @@
1-
Javascript Finite State Machine (v2.4.0)
2-
========================================
1+
# Javascript Finite State Machine (v2.4.0)
32

43
This standalone javascript micro-framework provides a finite state machine for your pleasure.
54

65
* You can find the [code here](https://github.com/jakesgordon/javascript-state-machine)
76
* You can find a [description here](http://codeincomplete.com/posts/2013/1/26/javascript_state_machine_v2_2_0/)
87
* You can find a [working demo here](http://codeincomplete.com/posts/2011/8/19/javascript_state_machine_v2/example/)
98

10-
Download
11-
========
9+
# Download
1210

1311
Using npm:
1412

15-
npm install --save javascript-state-machine
13+
npm install javascript-state-machine
1614

1715
Or download the source from [state-machine.js](https://github.com/jakesgordon/javascript-state-machine/raw/master/state-machine.js),
1816
or the [minified version](https://github.com/jakesgordon/javascript-state-machine/raw/master/state-machine.min.js)
1917

20-
Alternatively:
18+
# Usage
2119

22-
git clone git@github.com:jakesgordon/javascript-state-machine
23-
24-
25-
* All code is in state-machine.js
26-
* Minified version provided in state-machine.min.js
27-
* No 3rd party library is required
28-
* Demo can be found in /index.html
29-
* QUnit (browser) tests can be found in /test/index.html
30-
* QUnit (headless) tests can be run with "npm run test" (after "npm install")
31-
32-
Usage
33-
=====
34-
35-
Include `state-machine.js` in your web application, or, for npm `require("javascript-state-machine")`.
20+
Include `state-machine.js` in your web application, or, for npm `require('javascript-state-machine')`.
3621

3722
In its simplest form, create a standalone state machine using:
3823

@@ -60,8 +45,7 @@ along with the following members:
6045
* fsm.cannot(e) - return true if event `e` cannot be fired in the current state
6146
* fsm.transitions() - return list of events that are allowed from the current state
6247

63-
Multiple 'from' and 'to' states for a single event
64-
==================================================
48+
# Multiple 'from' and 'to' states for a single event
6549

6650
If an event is allowed **from** multiple states, and always transitions to the same
6751
state, then simply provide an array of states in the `from` attribute of an event. However,
@@ -92,8 +76,7 @@ allowed from any current state.
9276
>> NOTE: The `rest` event in the above example can also be specified as multiple events with
9377
the same name if you prefer the verbose approach.
9478

95-
Callbacks
96-
=========
79+
# Callbacks
9780

9881
4 types of callback are available by attaching methods to your StateMachine using the following naming conventions:
9982

@@ -175,8 +158,7 @@ You can affect the event in 3 ways:
175158
* return `false` from an `onleaveSTATE` handler to cancel the event.
176159
* return `ASYNC` from an `onleaveSTATE` handler to perform an asynchronous state transition (see next section)
177160

178-
Asynchronous State Transitions
179-
==============================
161+
# Asynchronous State Transitions
180162

181163
Sometimes, you need to execute some asynchronous code during a state transition and ensure the
182164
new state is not entered until your code has completed.
@@ -224,8 +206,7 @@ For example, using jQuery effects:
224206

225207
>> _NOTE: If you decide to cancel the ASYNC event, you can call `fsm.transition.cancel();`
226208
227-
State Machine Classes
228-
=====================
209+
# State Machine Classes
229210

230211
You can also turn all instances of a _class_ into an FSM by applying
231212
the state machine functionality to the prototype, including your callbacks
@@ -261,8 +242,7 @@ This should be easy to adjust to fit your appropriate mechanism for object const
261242
>> _NOTE: the `startup` event can be given any name, but it must be present in some form to
262243
ensure that each instance constructed is initialized with its own unique `current` state._
263244

264-
Initialization Options
265-
======================
245+
# Initialization Options
266246

267247
How the state machine should initialize can depend on your application requirements, so
268248
the library provides a number of simple options.
@@ -325,8 +305,7 @@ So you have a number of choices available to you when initializing your state ma
325305
that each instance gets its own unique `current` state, rather than an (unwanted) shared
326306
`current` state on the prototype object itself._
327307

328-
Handling Failures
329-
======================
308+
# Handling Failures
330309

331310
By default, if you try to call an event method that is not allowed in the current state, the
332311
state machine will throw an exception. If you prefer to handle the problem yourself, you can
@@ -343,20 +322,31 @@ define a custom `error` handler:
343322
]});
344323
alert(fsm.calm()); // "event calm was naughty :- event not allowed in current state green"
345324

346-
Release Notes
347-
=============
325+
# Contributing
326+
327+
> git clone git@github.com:jakesgordon/javascript-state-machine
328+
> cd javascript-state-machine
329+
330+
> npm install # install dev dependencies
331+
> npm start # run a local dev server
332+
333+
* Source code - `state-machine.js`
334+
* Minified code - `state-machine.min.js` (build with `npm run minify`)
335+
* Browse demo at `/`
336+
* Run tests in browser at `/test/`
337+
* Run tests in console with `npm test`
338+
* Please include tests with pull requests.
339+
340+
# Release Notes
348341

349342
See [RELEASE NOTES](https://github.com/jakesgordon/javascript-state-machine/blob/master/RELEASE_NOTES.md) file.
350343

351-
License
352-
=======
344+
# License
353345

354346
See [LICENSE](https://github.com/jakesgordon/javascript-state-machine/blob/master/LICENSE) file.
355347

356-
Contact
357-
=======
348+
# Contact
358349

359350
If you have any ideas, feedback, requests or bug reports, you can reach me at
360351
[jake@codeincomplete.com](mailto:jake@codeincomplete.com), or via
361352
my website: [Code inComplete](http://codeincomplete.com/)
362-

RELEASE_NOTES.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11

2-
FUTURE Version 3.0.0 (ETA - Early 2017)
3-
------------------------------
4-
5-
I know, I know, I've neglected this library for far too long, so
6-
lets get it back on track before the end of 2016
7-
8-
ADD: Promise based async transitions
9-
ADD: conditional transitions
10-
ADD: observable transitions
11-
ADD: composable state machines
12-
ADD: better introspection
13-
ADD: undo/redo history
14-
ADD: use camel casing for callback methods (instead of all lower case)
2+
FUTURE Version 3.0.0 (ETA - Early 2017)
3+
------------------------------
4+
5+
I know, I know, I've neglected this library for far too long, so lets get it back on track before the end of 2016...
6+
7+
ADD: Promise based async transitions
8+
ADD: conditional transitions
9+
ADD: observable transitions
10+
ADD: composable state machines
11+
ADD: better introspection
12+
ADD: undo/redo history
13+
ADD: use camel casing for callback/observer methods (instead of all lower case)
1514

16-
Version 2.4.0 (ETA - December 2016)
17-
--------------------
18-
19-
TODO: resolve outstanding github issues and pull requests
15+
Version 2.4.0 (ETA - November 2016)
16+
-----------------------------------
2017

2118
* added npm install instructions to readme
2219
* fix for javascript error when running in jasmine/node (issue #88)

bower.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"node_modules",
2323
"bower_components",
2424
"test",
25-
"tests",
2625
"demo",
2726
"index.html",
2827
".gitignore"

0 commit comments

Comments
 (0)