Update Main.elm

allow pushUrl to work without refreshing the page (calling init again). Taking inspiration from example app: https://github.com/ryannhg/elm-spa-realworld/blob/master/src/Main.elm#L84
This commit is contained in:
Adam Kirk 2020-11-25 21:29:00 -07:00 committed by GitHub
parent 51eb1976d4
commit 4a9d4f85c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,7 +84,11 @@ update msg model =
{ original | url = url }
( page, pageCmd ) =
Pages.init (fromUrl url) shared
if url.path == model.shared.url.path then
Pages.load model.page shared
else
Pages.init (fromUrl url) shared
in
( { model | page = page, shared = Pages.save page shared }
, Cmd.map Pages pageCmd