Thanks for the explanation!  Now that I understand what is happening I 
think I'll go with the fix described 
here https://groups.google.com/forum/#!topic/elm-discuss/F_oLy4PUF2o.  

Thanks,
Kevin
(Also, sorry for double posting!)

On Saturday, October 15, 2016 at 7:59:15 PM UTC-4, OvermindDL1 wrote:
>
> You will not be able to do that as Elm has its own scheduler that uses 
> `setTimeout(0, ...)` to do the event loops, including the very first init, 
> and that errors causes that event loop to die.  I'd probably recommend 
> changing your flags to handle this case differently or you might be able to 
> do it by setting up a port and messaging into it and maybe seeing if the 
> port exists (if it does not exist it all then the app may not have loaded, 
> I've not tested this to see 'when' the ports are setup in the setup but you 
> could always have the program message back 'out' if it was successful, 
> though I'd go with changing how the data is passed in).
>
> On Saturday, October 15, 2016 at 11:20:11 AM UTC-6, Kevin Berridge wrote:
>>
>> I'm using App.programWithFlags to initialize the state of my model from 
>> local storage (as described in this blog article 
>> <https://medium.com/wunder-nerds/storing-and-restoring-the-state-in-elm-0-17-94874429dc1d>).
>>  
>>  But when the schema of my model changes (ex: I added a new field to a 
>> record type) it will correctly error out when Elm.Main.fullscreen is called 
>> with error: "You are trying to initialize module `Main` with an unexpected 
>> argument."
>>
>> I am OK with throwing away the state from local storage and starting from 
>> scratch when this happens, so I tried to add a try catch in the JavaScript 
>> but surprisingly (to me) the catch doesn't fire.
>>
>> try {
>>     elmApp = Elm.Main.fullscreen(startingState);
>> }
>> catch (e) {
>>     elmApp = Elm.Main.fullscreen(null); // this never gets called
>> }
>>
>> Is there a way that I can catch this error?  Or do I need to use a 
>> different approach?
>>
>> Thanks,
>> Kevin
>>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to