share waiting with parametric lenses
[mTask.git] / miTask.icl
index 8e43544..f044e36 100644 (file)
@@ -37,9 +37,20 @@ demo = viewSharedInformation "Devices" [] deviceStore
                pred [x:_] = not $ isEmpty x.deviceShares
 
                cont :: MTaskDevice -> Task ()
-               cont dev = updateSharedInformation "Blinkyblink" [] (getRealShare dev (hd dev.deviceShares))
-                       >>* [OnAction ActionContinue (const $ Just $ cont dev)]
-       
+               cont dev
+               # rs = getRealShare dev (hd dev.deviceShares)
+               = get rs >>= \oldvalue->
+                       forever (updateSharedInformation "Blinkyblink" [] (getRealShare dev (hd dev.deviceShares))
+                       >>* [OnAction ActionContinue (const $ Just $ treturn ())])
+                -|| (wait "bigger than 10" (\x->x == oldvalue) rs
+                       >>= viewInformation "Bigger:)" [])
+
+               toInt :: BCValue -> Int
+               toInt (BCValue e) = dynToInt (dynamic e)
+                       
+               dynToInt :: Dynamic -> Int
+               dynToInt (a :: Int) = a
+               dynToInt x = abort "Not an int"
 
 mTaskManager :: Task ()
 mTaskManager = (>>|) startupDevices $