Suppose I have some application that can be in one of various states. The
application also has say a menu and a dialog, each with their own states.
The dialog and menu are not always shown, but they can also be shown at the
same time. This gives me quite a large cross product of the state space to
enumerate:
type State =
App1
| App2
| ...
| App1WithMenu Menu
| ...
| App1WithMenuAndDialog Menu Dialog
Which is not going to be very practical.
I am thinking instead that the menu and dialog state spaces should also
include some kind of default inactive state. Lets just call it Hidden.
type Menu =
Hidden
| Menu1
| ...
type Dialog =
Hidden
| Dialog1
| ...
Now these state spaces can be made always present in the application model:
type alias Model =
{ dialog : Dialog,
menu : Menu,
app : State
}
And the 'view' functions for them can even return optional results, so that
nothing is rendered when they are hidden. 'view : Menu -> Maybe (Html Msg)'.
This does mean though, that the whole cross product of the state space can
be represented. Perhaps there are some combinations of states that I want
to disallow - for example, maybe I do not want to allow the menu to be
opened when the dialog is already open. I can encode these rules in some
state transition functions that enforce them, but I have lost the nice
quality of eliminating even the possibility of them existing in the data
model.
Just wondering if anyone has tried this kind of thing on a larger
application and what you think worked best?
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.