You could load the raw data into the app using Value instead of whatever
you have now and create a series of Json Decoders for each version of the
schema.
You could then use Json.Decode.oneOf to produce the current structure from
any of the old schemas.

You could also use a schema version field on the data and then do the
decoding in two parts using Json.Decod.andThen




On Tue, Nov 8, 2016 at 5:02 PM, Jacky See <[email protected]> wrote:

> I have an Elm app that would store the entire model into the local
> storage, using `programWithFlags` to feed in the data directly when `init`.
> As the app develop, more fields is added to the model so there will be
> model mismatch between localStorage and the new model and Elm would fail at
> the JS side when trying to init.
> Obviously, there should be some migration plan here at the js side to
> update the stored model to the new shape.
> Personally, I wish I could have something like Json.Decode to handle the
> model directly in Elm, maybe peform a task?
> What would you guys recommend to do?
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to