rev: tip truffle/src/Main.fs -rw-r--r-- 849 bytes View raw Log this file
5dc280cc3b6dTim Knauf Corrected title on HTML template. a month ago
                                                                                
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
module App

open Elmish
open System
open Fable.Core

open Types
open Model
open View

open Elmish.HMR // Elmish.HMR needs to be the last open instruction in order to be able to shadow any supported API

let init () =
    if Cheat.manualSaves then
        State.create, Cmd.ofMsg (Tick DateTime.Now)
    else
        Persistence.load State.create, Cmd.ofMsg (Tick DateTime.Now)

let timer onTick =
    let start dispatch =
        let intervalId = 
            JS.setInterval
                (fun _ -> dispatch (onTick DateTime.Now))
                250
        { new IDisposable with
            member _.Dispose() = JS.clearInterval intervalId }
    start
    
let subscribe model =
    [ ["timer"], timer Tick ]

Program.mkProgram init update render
|> Program.withSubscription subscribe
|> Program.withReactSynchronous "feliz-app"
|> Program.run