-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModel.elm
56 lines (42 loc) · 1001 Bytes
/
Model.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
module Model exposing (Model, initialModel)
import Type.Contact exposing(Contact)
import Type.Chat exposing(Chat)
-- Data Types
type alias Id =
String
type Container
= Horizontal (List Container)
| Vertical (List Container)
| Node Chat
type alias Model =
{ userId: Maybe Id
, friendList : List Contact
, chats: Container
}
-- Initial Model
initialModel : Model
initialModel =
{ userId : Nothing
, friendList : []
, chats : Horizontal []
}
-- Model Public API
setUserId : Maybe Id -> Model -> Model
setUserId userId model =
{ model | userId = userId }
setFriendList : List Contact -> Model -> Model
setFriendList friendList model =
{ model | friendList = friendList }
setChats : Container -> Model -> Model
setChats container model =
{ model | container = container }
getUserId : Model -> Maybe Id
getUserId =
.userId
getFriendList : Model -> List Contact
getFriendList =
.friendList
getChats : Model -> Container
getChats =
.chats
-- Model Private API