change AppUpdate.update function to return a list, so we can return multiple messages from a single event
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
signature UPDATE_THREAD =
|
||||
sig
|
||||
val run:
|
||||
InputMessage.t Mailbox.mbox
|
||||
InputMessage.t Mailbox.mbox
|
||||
* DrawMessage.t Mailbox.mbox
|
||||
* FileMessage.t Mailbox.mbox
|
||||
* AppType.app_type
|
||||
@@ -17,13 +17,20 @@ struct
|
||||
case updateMsg of
|
||||
DRAW drawMsg => Mailbox.send (drawMailbox, drawMsg)
|
||||
| FILE fileMsg => Mailbox.send (fileMailbox, fileMsg)
|
||||
| NO_MAILBOX => ()
|
||||
|
||||
fun handleMsgs (drawMailbox, fileMailbox, lst) =
|
||||
case lst of
|
||||
hd :: tl =>
|
||||
let val _ = handleMsg (drawMailbox, fileMailbox, hd)
|
||||
in handleMsgs (drawMailbox, fileMailbox, tl)
|
||||
end
|
||||
| [] => ()
|
||||
|
||||
fun loop (inputMailbox, drawMailbox, fileMailbox, model) =
|
||||
let
|
||||
val inputMsg = Mailbox.recv inputMailbox
|
||||
val (model, updateMsg) = AppUpdate.update (model, inputMsg)
|
||||
val _ = handleMsg (drawMailbox, fileMailbox, updateMsg)
|
||||
val (model, updateMsgs) = AppUpdate.update (model, inputMsg)
|
||||
val _ = handleMsgs (drawMailbox, fileMailbox, updateMsgs)
|
||||
in
|
||||
loop (inputMailbox, drawMailbox, fileMailbox, model)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user