forked from supermario/lamdera-realworld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Types.elm
60 lines (45 loc) · 1.36 KB
/
Types.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
57
58
59
60
module Types exposing (..)
import Api.Article exposing (ArticleStore, Slug)
import Api.Article.Comment exposing (Comment)
import Api.User exposing (User, UserFull, UserId)
import Bridge
import Browser
import Browser.Navigation exposing (Key)
import Dict exposing (Dict)
import Gen.Pages as Pages
import Lamdera exposing (ClientId, SessionId)
import Shared
import Time
import Url exposing (Url)
type alias FrontendModel =
{ url : Url
, key : Key
, shared : Shared.Model
, page : Pages.Model
}
type alias BackendModel =
{ sessions : Dict SessionId Session
, users : Dict Int UserFull
, articles : Dict Slug ArticleStore
, comments : Dict Slug (Dict Int Comment)
}
type alias Session =
{ userId : Int, expires : Time.Posix }
type FrontendMsg
= ChangedUrl Url
| ClickedLink Browser.UrlRequest
| Shared Shared.Msg
| Page Pages.Msg
| Noop
type alias ToBackend =
Bridge.ToBackend
type BackendMsg
= CheckSession SessionId ClientId
| RenewSession UserId SessionId ClientId Time.Posix
| ArticleCreated Time.Posix (Maybe UserFull) ClientId { title : String, description : String, body : String, tags : List String }
| ArticleCommentCreated Time.Posix (Maybe UserFull) ClientId Slug { body : String }
| NoOpBackendMsg
type ToFrontend
= ActiveSession User
| PageMsg Pages.Msg
| NoOpToFrontend