ContaSystemer / elm-effects / Effects

In Elm all effects are managed (no side effects) and described with commands and subscriptions (Cmd msg, Sub msg). Only private organisations/people have access to add/describe new effects.

Effects module helps to manage additional program effects. For instance effects can be used for communication between programs. It make sense especially for programs described as a composition of sub-programs. A program effect should be supplied by a consumer.

Create


type Effects effect

Describes a collection of program effects.

none : Effects effect

Creates no effect. Useful when a program does not produce any effects.

from : effect -> Effects effect

Creates an effect. Useful to create an instance of a program effect.

batch : List (Effects effect) -> Effects effect

Batches multiple effects. Useful when a program produces multiple effects.

Transform

map : (effectA -> effectB) -> Effects effectA -> Effects effectB

Transforms an effect. Useful when combining multiple programs together.

apply : (effect -> value -> value) -> value -> Effects effect -> value

Applies all effects to given initial value. Useful to apply effects produced by a program.

applyWithPriority : (effect -> value -> value) -> (effect -> Basics.Int) -> value -> Effects effect -> value

Applies all effects to given initial value by given priority. Useful to apply effects produced by a program. Effects with lover priority are applied first.