Code Monkey home page Code Monkey logo

Comments (8)

jgrenat avatar jgrenat commented on June 14, 2024 1

I've tried reshaping the model and you're right, it now works with:

type AppModel
    = NeedAuthentication
    | OAuthError OAuth.Implicit.AuthorizationError
    | NotReady { flags : Flags, sharedState : { navigationKey : Key }, token : Token, url : Url }
    | InvalidFlags
    | Ready Model

This is a quick (and dirty) fix but I'll take some time at the end of the week to look at the elm-hot code and see if I find a good idea :)

Thanks a lot @klazuka !

from elm-hot.

klazuka avatar klazuka commented on June 14, 2024

what does your top level Model type look like? If you don't want to post it online, you can DM me on Slack.

from elm-hot.

klazuka avatar klazuka commented on June 14, 2024

(accidentally clicked 'close')

from elm-hot.

jgrenat avatar jgrenat commented on June 14, 2024

This looks like this:

type AppModel
    = NeedAuthentication
    | OAuthError OAuth.Implicit.AuthorizationError
    | NotReady Flags Key Token Url
    | InvalidFlags
    | Ready Model

type alias Model =
    { page : Page
    , sharedState : SharedState
    }

type alias SharedState =
    { navigationKey : Key
    , timeZone : Time.Zone
    , imagePaths : ImagePaths
    , oAuthToken : Token
    }

from elm-hot.

jgrenat avatar jgrenat commented on June 14, 2024

(Note that the navigation key can be found at two different places, maybe it's because of that?)

from elm-hot.

klazuka avatar klazuka commented on June 14, 2024

That's almost certainly the problem. elm-spa-example also stores the key in "multiple" places, but it's always the first parameter of a variant. So the key-path (the sequence of JS properties that need to be dereferenced) to the Browser.Navigation.Key is the same for all variants. Whereas in your case the key-path to the nav key changes.

Fixing this in elm-hot will be hard. We assume that the place where we originally found the NavKey will be the same for subsequent app reloads. I think your best course of action is to find an alernative that uses message-based replay (maybe this?) or, if possible, change the shape of your root model so that the NavKey is always in the "same" relative location.

from elm-hot.

klazuka avatar klazuka commented on June 14, 2024

If you can come up with a good fix, I'd be open to a PR. But the code is already too gnarly, so it'd have to be a pretty clean fix.

from elm-hot.

sebbes-at-deepgram avatar sebbes-at-deepgram commented on June 14, 2024

I just ran into this exact same issue. Aligning the "js paths" fixed the issue. I understood the fix would be very hard and I took me some time to find this issue. What about pointing to this issue in the error message or a short documentation page?

@klazuka

from elm-hot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.