tricycle/elm-eventstream/1.1.1

Renamed to bellroy/elm-eventstream. It is published under that name, and new versions come out there.

Versions published as tricycle/elm-eventstream still install under that name. 2 versions of 3 come from the new location (see their notes). 1 version could not be recovered and cannot be installed.

Rerouted (cache, verified). The original is gone. This copy comes from a Lamdera package cache made before it went. The Lamdera package server serves a copy recovered from a Lamdera package cache from 2021-02-13.

What we checked: Rebuilt from the unpacked sources in a Lamdera package cache (5 copies agree), which Elm only writes after the published SHA-1 checked out; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip is our own, so its SHA-1 is not the published one.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/tricycle/elm-eventstream/zipball/1.1.1/

Elm EventStream

Allows you to setup a "stream" of Events. For every event you are required to setup a name and decoder to validate it's contents. Triggers can be placed to listen to events and consolidate the data in to a new outgoing event.

Usage

Creating a new EventStream

eventMatcher : Matcher -> Decode.Decoder Bool
eventMatcher matcher =
    Decode.field "eventData"
        (Decode.field "someField" Decode.string
            |> Decode.andThen
                (\someFieldValue ->
                    if matcher == ("TestEvent." ++ someFieldValue) then
                        Decode.succeed True

                    else
                        Decode.succeed False
                )
        )

testEventEncoder : Matcher -> Decode.Value -> Result EventStream.Error Encode.Value
testEventEncoder matcher rawEvent =
    Ok <| Encode.string "outgoing"

eventStream =
    EventStream.init
        [ ( "TestEvent", eventMatcher )
        ]
        [ ( "TestEvent", testEventEncoder ) ]

Adding a new Event to the EventStream

(updatedEventStream, listOfOutgoingEvents) =
    EventStream.addEvent anEncodedValue eventStream