Skip to content

Extend scotty global state example to add timer modifying state at regular intervals

License

Notifications You must be signed in to change notification settings

sgdan/scotty-timerstate

Repository files navigation

scotty-timerstate

Extends the scotty global state example slightly to add a background timer thread that modifies the state at regular intervals.

Use make shell to create and start a docker container based on Nix with the build environment - around 3.8 Gigs! Once you have the [nix-shell:/working]# prompt you can build and run using nix commands or cabal (easier for dev).

nix-build release.nix
result/bin/scotty-timerstate
cabal run scotty-timerstate

Once running on http://localhost:3000 you can trigger manual state changes by going to http://localhost:3000/plusone and http://localhost:3000/plustwo. After a while you should see an increased tickCount value and various channel values in the JSON returned by the server e.g.

{"channels":["timer","timer","timer","plustwo","timer","plusone","timer","timer","initial"],"tickCount":21}

After updating dependencies in working.cabal use cabal2nix . > default.nix to update the nix configuration.

Useful links

About

Extend scotty global state example to add timer modifying state at regular intervals

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published