Elm-reactor with flags?

Hi all,

I have an app using flags (I’m saving the state in local storage and retrieving it on startup), and I also have custom HTML to pull in my CSS.

When I try to run elm-reactor, I get the following:

Oops! Something went wrong when starting your Elm program.
Trying to initialize the ZKMain module with an unexpected flag.
I tried to convert it to an Elm value, but ran into this problem:

I ran into the following problems:

Expecting null but instead got: undefined
Expecting an object with a field named pageStr but instead got: undefined

Is there a way to get it to work? Where can I find documentation? I did some googling but I mainly found tickets, not docs.


You could have elm-reactor serve custom HTML like Ilias described. Personally I prefer having a Reactor.elm entry point that supplies default flags to the main function of Main.elm

module Main exposing (main, reactor)
main =
        { init = init
        -- ...

defaultFlags =
     -- Your reactor flags

reactor =
        { init = init defaultFlags
        -- ...

init flags =
    -- ...
module Reactor exposing (main)

import Main

main =

Very nice solution! Thanks :slight_smile:

1 Like

Another way is to use type alias Flags = Value and decode them in the init function, providing default values. You can check the example here.

1 Like