[server] Add very simple animation module

I mostly used this module for testing the partial tree updates.
This commit is contained in:
Joscha 2020-02-12 11:07:12 +00:00
parent b2b34d551a
commit 3656483bc8
2 changed files with 43 additions and 0 deletions

View 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]