chazsconi / elm-phoenix-ports / Phoenix.Presence

Presence is an extension for channels to support the Presence feature of Phoenix.

Definition


type alias Presence msg =
PhoenixPresence msg

Representation of a Presence configuration

Helpers

create : PhoenixPresence msg

Create a Presence configuration

onChange : (Dict String (List Json.Decode.Value) -> msg) -> PhoenixPresence msg -> PhoenixPresence msg

This will be called each time the Presence state changes. The Dict contains as keys your presence keys and as values a list of the payloads you sent from the server. If you have on the elixir side Presence.track(socket, user_name, %{online_at: now()}) then an example would be a Dict with

{ "user1": [{online_at: 1491493666123}]
, "user2": [{online_at: 1491492646123}, {online_at: 1491492646624}]
}

onJoins : (Dict String (List Json.Decode.Value) -> msg) -> PhoenixPresence msg -> PhoenixPresence msg

This will be called each time user some user joins. This callback is useful to have special events if a user joins. To obtain a list of all users use onChange.

onLeaves : (Dict String (List Json.Decode.Value) -> msg) -> PhoenixPresence msg -> PhoenixPresence msg

This will be called each time user some user leaves. This callback is useful to have special events if a user leaves. To obtain a list of all users use onChange.

map : (a -> b) -> PhoenixPresence a -> PhoenixPresence b

Maps the callbacks