Comments (8)
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.
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.
(accidentally clicked 'close')
from elm-hot.
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.
(Note that the navigation key can be found at two different places, maybe it's because of that?)
from elm-hot.
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.
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.
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?
from elm-hot.
Related Issues (20)
- [elm-hot] Browser.Navigation.Key def not found. Version mismatch HOT 2
- Cannot make it work with elm-spa-example HOT 4
- Ignore the provided DOM node in init for "fullscreen" Elm apps
- Application hangs without Browser.Navigation.Key stored in Model HOT 2
- Elm Hot do not work with Browser.Navigation.Key HOT 2
- Store messages instead of `model`? HOT 4
- Could not find Browser.Navigation.Key in your model with Browser.application HOT 8
- Add 'height: inherit' to the injected DOM container node
- Cannot init a headless Program HOT 3
- Add a "verbose" flag to enable/disable console.log HOT 3
- Do not assume that every program defines `List.map` HOT 13
- Hot reload failing HOT 1
- Breaks with elm/browser 1.0.2 HOT 3
- Failing to find old key because navKeyPath changes HOT 2
- Build error if there are a space in the path.
- Error "Cannot read property 'hasOwnProperty' of undefined" HOT 1
- Preserve scroll position on body
- Small conflict with elm-optimize-level-2 HOT 1
- the location of the Browser.Navigation.Key in the model has changed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elm-hot.