-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
State machines #38
State machines #38
Conversation
content/guides/state-machines.md
Outdated
Or in a more compact notation: | ||
|
||
```js | ||
var stateMachine => (t, c, n) => t[c][n] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first =>
should be =
content/guides/state-machines.md
Outdated
If you're looking for a solid state machine implementation, check out | ||
[choojs/nanostate](https://github.com/choojs/nanostate). It's similar to the | ||
state machine we implemented in the section above, but adds event hooks, clean | ||
error messages and more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oxford comma? (, and more)
Super well done, caught some typos for ya! |
Pushed fixes! Thanks @bendrucker ✨ |
content/guides/state-machines.md
Outdated
# state machines | ||
If you work in software long enough, you'll have to deal with legacy codebases. | ||
but you'll also have had the chance to start projects from scratch. And | ||
eventually see your project become a legacy codebase itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventually you'll see [...]
``` | ||
|
||
And that's the basics. From here we could go on to add more states and | ||
transitions, expanding the graph. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
graph here introduces a concept that previously hasnt been talked about, might be good to add a representation of the state machine as a graph, visually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but don't have any graph tools around right now. If someone has a graph that'd be neat!
content/guides/state-machines.md
Outdated
## State machines in JavaScript | ||
Let's implement the traffic light example in JavaScript. In order for this to | ||
work, we'll need to implement: | ||
- save the states & transitions in an Object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saving
content/guides/state-machines.md
Outdated
work, we'll need to implement: | ||
- save the states & transitions in an Object | ||
- the core state machine algorithm | ||
- create a small, stateful class to hold the state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creating
content/guides/state-machines.md
Outdated
- save the states & transitions in an Object | ||
- the core state machine algorithm | ||
- create a small, stateful class to hold the state | ||
- combine all of these to form the complete state machine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
combining
content/guides/state-machines.md
Outdated
|
||
### Class | ||
While the state machine algorithm is quite simple, it requires us to keep track | ||
of what the current state is. This means that statemachines themselves are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state machines
- Nested state machines. | ||
|
||
We'll leave this as an exercise up to the reader. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo this is missing usage examples in user interface design, as hinted at during the first section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aye, yeah fair
Made an issue for the last unsolved comment. Merging now, will fix the remaining comments later! ✨ V. excited to have some of these sections up! 😁 |
Adds a section about state machines: what to use them for, and how to implement one. Thanks!