Created
April 6, 2017 14:08
-
-
Save saschatimme/4550253a712ca352edba1154043c24f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Phoenix.Presence exposing (Presence, create, onChange, onJoins, onLeaves) | |
import Dict exposing (Dict) | |
import Json.Decode as JD exposing (Decoder, Value) | |
type alias Presence msg = | |
PhoenixPresence msg | |
type alias PhoenixPresence val msg = | |
{ onChange : Maybe (Dict String (List Value) -> msg) | |
, onJoins : Maybe (Dict String (List Value) -> msg) | |
, onLeaves : Maybe (Dict String (List Value) -> msg) | |
} | |
create : PhoenixPresence val msg | |
create = | |
{ onChange = Nothing | |
, onJoins = Nothing | |
, onLeaves = Nothing | |
} | |
onChange : (Dict String (List Value) -> msg) -> PhoenixPresence msg -> PhoenixPresence msg | |
onChange func presence = | |
{ presence | onChange = Just func } | |
onJoins : (Dict String (List Value) -> msg) -> PhoenixPresence msg -> PhoenixPresence msg | |
onJoins func presence = | |
{ presence | onJoins = Just func } | |
onLeaves : (Dict String (List Value) -> msg) -> PhoenixPresence msg -> PhoenixPresence msg | |
onLeaves func presence = | |
{ presence | onLeaves = Just func } | |
{- And in Channel -} | |
withPresence : Presence msg -> Channel msg -> Channel msg | |
withPresence presence chan = | |
{ chan | presence = Just presence } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment