blob: 6e75c39607779b4e0753d40e35935a7d46e86a7a (
plain)
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
|
module Model exposing
( Model
, init
, numberOfTimers
)
import Dict exposing (Dict)
import Dict
import Time exposing (Time)
import List
import Msg exposing (Msg)
import Model.Id exposing (..)
import Model.IdGenerator exposing (..)
import Timer.Model as Timer exposing (Timer)
import Edition.Model exposing (Edition)
type alias Model =
{ time : Time
, timers : Dict Id Timer
, timerIdGenerator : IdGenerator
, edition : Maybe Edition
}
init : Time -> (Model, Cmd Msg)
init initialTime =
let (id, idGenerator) = getId initialIdGenerator
model =
{ time = initialTime
, timers = Dict.insert id (Timer.init initialTime) Dict.empty
, timerIdGenerator = idGenerator
, edition = Nothing
}
in (model, Cmd.none)
numberOfTimers : Model -> Int
numberOfTimers = List.length << Dict.toList << .timers
|