This module provides an Effect
type that carries both Cmd and messages for
a shared update
A collection of shared and platform effects
none : Effect sharedMsg msg
Tells that there are no effects
batch : List (Effect sharedMsg msg) -> Effect sharedMsg msg
Batch effects. Similar to
Cmd.batch
fromCmd : Platform.Cmd.Cmd msg -> Effect sharedMsg msg
Build an effect from a Cmd
fromSharedCmd : Platform.Cmd.Cmd sharedMsg -> Effect sharedMsg msg
Build an effect from a shared Cmd. The result of this command will be handled by the shared update no matter where it is emitted from
fromShared : sharedMsg -> Effect sharedMsg msg
Build an effect from a shared Msg. The message will be sent as-is to the shared update
perform : (a -> msg) -> Task Basics.Never a -> Effect sharedMsg msg
Build an effect that performs a Task
attempt : (Result x a -> msg) -> Task x a -> Effect sharedMsg msg
Build an effect that attempts a Task
map : (a -> b) -> Effect sharedMsg a -> Effect sharedMsg b
Transform the messages produced by an Effect. Similar to
Cmd.map
.
These functions join an effect to a given model, for using pipeline syntax in your 'update' functions
with : Effect sharedMsg msg -> model -> ( model, Effect sharedMsg msg )
Wraps the model with the given Effect
withNone : model -> ( model, Effect sharedMsg msg )
Wraps the model with Effect.none
init : ( Model, Effect Msg )
init =
myModel
|> Effect.withNone
withBatch : List (Effect sharedMsg msg) -> model -> ( model, Effect sharedMsg msg )
Wraps the model with a list of Effect
init : ( Model, Effect Msg )
init =
myModel
|> Effect.withBatch [ someEffect, anotherEffect ]
withCmd : Platform.Cmd.Cmd msg -> model -> ( model, Effect sharedMsg msg )
Wraps the model with a Cmd
init : ( Model, Effect Msg )
init =
myModel
|> Effect.withCmd someCmd
withSharedCmd : Platform.Cmd.Cmd sharedMsg -> model -> ( model, Effect sharedMsg msg )
Wraps the model with a shared Cmd
init : ( Model, Effect Msg )
init =
myModel
|> Effect.withCmd Shared.refreshIdentity
withShared : sharedMsg -> model -> ( model, Effect sharedMsg msg )
Wraps the model with a shared Msg
init : ( Model, Effect Msg )
init =
myModel
|> Effect.withCmd Shared.clearCache
withMap : (msg1 -> msg) -> Effect sharedMsg msg1 -> model -> ( model, Effect sharedMsg msg )
Wraps the model with a mapped effect. Should only be used in top-level packages
init : ( Model, Effect Msg )
init =
myModel
|> Effect.withMap SharedMsg Shared.refreshIdentity
withPerform : (a -> msg) -> Task Basics.Never a -> model -> ( model, Effect sharedMsg msg )
Wraps the model with an effect that performs a Task
withAttempt : (Result x a -> msg) -> Task x a -> model -> ( model, Effect sharedMsg msg )
Wraps the model with an effect that attempts a Task
These functions add a new effect to a given (model, effect) pair, for using pipeline syntax in your 'update' functions
add : Effect sharedMsg msg -> ( model, Effect sharedMsg msg ) -> ( model, Effect sharedMsg msg )
Add a new Effect to an existing model-Effect pair
addBatch : List (Effect sharedMsg msg) -> ( model, Effect sharedMsg msg ) -> ( model, Effect sharedMsg msg )
Add a list of new Effect to an existing model-Effect pair
addCmd : Platform.Cmd.Cmd msg -> ( model, Effect sharedMsg msg ) -> ( model, Effect sharedMsg msg )
Add a Cmd
to an existing
model-Effect pair
addSharedCmd : Platform.Cmd.Cmd sharedMsg -> ( model, Effect sharedMsg msg ) -> ( model, Effect sharedMsg msg )
Add a shared Cmd
to an existing
model-Effect pair
( model, effect )
|> Effect.addShared Shared.renewToken
addShared : sharedMsg -> ( model, Effect sharedMsg msg ) -> ( model, Effect sharedMsg msg )
Add a new shared Msg to an existing model-Effect pair
( model, effect )
|> Effect.addShared Shared.clearCache
addMap : (msg1 -> msg) -> Effect sharedMsg msg1 -> ( model, Effect sharedMsg msg ) -> ( model, Effect sharedMsg msg )
Add a new mapped Effect to an existing model-Effect pair
addPerform : (a -> msg) -> Task Basics.Never a -> ( model, Effect sharedMsg msg ) -> ( model, Effect sharedMsg msg )
Add an effect that performs a Task to an existing model-Effect pair
addAttempt : (Result x a -> msg) -> Task x a -> ( model, Effect sharedMsg msg ) -> ( model, Effect sharedMsg msg )
Add an effect that attempts a Task to an existing model-Effect pair
toCmd : ( sharedMsg -> msg, subMsg -> msg ) -> Effect sharedMsg subMsg -> Platform.Cmd.Cmd msg
Convert a collection of effects to a collection of
Cmd
extractShared : Effect sharedMsg msg -> ( List sharedMsg, Effect sharedMsg msg )
Extract the Shared messages from an effect
Useful for an application that wants to apply Shared effects immediately instead of using tasks (which is what toCmd does)