[server] Add very simple animation module
I mostly used this module for testing the partial tree updates.
This commit is contained in:
parent
b2b34d551a
commit
3656483bc8
2 changed files with 43 additions and 0 deletions
26
src/Forest/TreeModule/AnimateModule.hs
Normal file
26
src/Forest/TreeModule/AnimateModule.hs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Forest.TreeModule.AnimateModule
|
||||
( AnimateModule
|
||||
, animateModule
|
||||
) where
|
||||
|
||||
import Control.Concurrent
|
||||
|
||||
import Forest.TreeModule
|
||||
import Forest.Node
|
||||
import Forest.Util
|
||||
|
||||
data AnimateModule = AnimateModule
|
||||
|
||||
instance TreeModule AnimateModule where
|
||||
|
||||
animateModule :: Int -> [Node] -> ModuleConstructor AnimateModule
|
||||
animateModule delay frames sendNode continue =
|
||||
withThread (animateThread frames) $ continue AnimateModule
|
||||
where
|
||||
animateThread [] = sendNode $ txtNode "" "Invalid animation: No frames provided"
|
||||
animateThread (x:xs) = do
|
||||
sendNode x
|
||||
threadDelay delay
|
||||
animateThread $ xs ++ [x]
|
||||
Loading…
Add table
Add a link
Reference in a new issue