Cross-cutting shared state management.
The shared state is global state accessible to all pages. Pages read it through their function signatures (it's passed to init, view, subscriptions) and update it through Effects.
Users define their own shared type and provide init/update/subscriptions:
type alias Shared =
{ user : Maybe User
, theme : Theme
, apiUrl : String
}
sharedConfig : SharedConfig Flags Shared SharedMsg
sharedConfig =
App.Shared.sharedConfig
{ init = \flags -> ( { user = Nothing, theme = Light, apiUrl = flags.apiUrl }, Cmd.none )
, update = \msg shared -> ( shared, Cmd.none )
, subscriptions = \shared -> Sub.none
}
Configuration for shared state management. Opaque type that bundles init, update, and subscriptions for the shared state.