orus-io/elm-spa/1.3.0

NOTE: the latest version is 3.0.1

Effect

This module provides a Effect type that carry both Cmd and messages for a shared update

Create

type Effect sharedMsg msg

A collection of shared and platform effects

none : Effect sharedMsg msg

Tells that there are no effect

batch : List (Effect sharedMsg msg) -> Effect sharedMsg msg

Batch effects. Similar to Cmd.map

fromCmd : Cmd msg -> Effect sharedMsg msg

Build an effect from a Cmd

fromSharedCmd : 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 send as-is to the shared update

perform : (a -> msg) -> Task 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

Transform

map : (a -> b) -> Effect sharedMsg a -> Effect sharedMsg b

Transform the messages produced by an Effect. Similar to Cmd.map.

( sharedMsg -> msg, subMsg -> msg )
-> Effect sharedMsg subMsg
-> Cmd msg

Convert a collection of effect to a connection of Cmd

Join effect to a model

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
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 : Cmd msg -> model -> ( model, Effect sharedMsg msg )

Wraps the model with a Cmd

init : ( Model, Effect Msg )
init =
    myModel
        |> Effect.withCmd someCmd
withSharedCmd : 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
(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 Never a -> model -> ( model, Effect sharedMsg msg )

Wraps the model with an affect that performs a Task

(Result x a -> msg)
-> Task x a
-> model
-> ( model, Effect sharedMsg msg )

Wraps the model with an affect that attempts a Task

Add effect to a (model, effect) pair

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

List (Effect sharedMsg msg)
-> ( model, Effect sharedMsg msg )
-> ( model, Effect sharedMsg msg )

Add a list of new Effect to an existing model-Effect pair

Cmd msg
-> ( model, Effect sharedMsg msg )
-> ( model, Effect sharedMsg msg )

Add a Cmd to an existing model-Effect pair

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
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
(msg1 -> msg)
-> Effect sharedMsg msg1
-> ( model, Effect sharedMsg msg )
-> ( model, Effect sharedMsg msg )

Add a new mapped Effect to an existing model-Effect pair

(a -> msg)
-> Task Never a
-> ( model, Effect sharedMsg msg )
-> ( model, Effect sharedMsg msg )

Add an affect that performs a Task to an existing model-Effect pair

(Result x a -> msg)
-> Task x a
-> ( model, Effect sharedMsg msg )
-> ( model, Effect sharedMsg msg )

Add an affect that attempts a Task to an existing model-Effect pair