The Effect type wraps Cmd with shared state updates and navigation.
Pages return Effect msg instead of Cmd msg from their update functions
when they need to update shared state or navigate. The App module interprets
Effects into actual Cmds.
update : Msg -> Model -> ( Model, Effect Msg )
update msg model =
case msg of
LoggedIn user ->
( model
, Effect.batch
[ Effect.updateShared (\s -> { s | user = Just user })
, Effect.pushUrl "/"
]
)
FetchData ->
( model
, Effect.sendCmd (Http.get { ... })
)Navigate to a URL (adds to browser history).
Effect.pushUrl "/blog/42"Navigate to a URL without adding to browser history.
Navigate to an external URL. This triggers a full page load, leaving the SPA.
An effect that the App module interprets.
None: no effectBatch: combine multiple effectsSendCmd: a regular Elm CmdUpdateShared: modify the shared statePushUrl: navigate to a new URL (adds to history)ReplaceUrl: navigate without adding historyBack: go back N steps in historyLoadExternalUrl: navigate to an external URL (full page load)