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.