Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Traffic Light State Machine in Microstates

NotificationsYou must be signed in to change notification settings

microstates/trafficlight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build StatusCoverage StatusCreated by The FrontsideChat on Discord

Traffic Light State Machine with Microstates

CheckoutMicrostates.js Project if you haven't already.

Demo on CodeSandbox

This application is an example of using Microstates to build State Machines. This is one of the popular examples of state machines but it adds a small Microstaty twist. It shows how you an compose state machines and transition state one state machine based on another.

In this example, hasTrafficLight state machine and aPerson state machine. When the traffic light is red, the pedastrian stands and waits, runs when it's yellow and walks when it's green. Both state machines are composed into anIntersection state machine.

The file structure has/src/states directory where all of the state machines and their tests are./src/components directory has components for rendering the state machines. The state machines are brought to live by anInterval component which calls Intersection's tick transition every minute.

Intallation

  1. Clone this repogit clone git@github.com:microstates/trafficlight.git
  2. Install npm dependencies withyarn ornpm install
  3. yarn start ornpm start to start the server

Testing

You can run tests withyarn test ornpm test.

Contributing

PRs and Questions are welcome.

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp