[elm-discuss] Re: Call of init function behaviour
Thank you for your reply. I have solved my problem after looking hours and hours on my code :) The problem was that I had a button that calls to the backend which I described in my question and the problem was that the button was in a Html.form. Apparently it will first trigger the action and than reloads the page and triggers the init function again. So Nicholas we had the right answer independently. Sorry for the noise but maybe I could help other people with the answer :) thx \= odi -- 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.
[elm-discuss] Call of init function behaviour
When will the init function call? I have a strange (for me) behaviour in my flow. I have a backend call in which some entity will be saved. I have a page redirect logic e.g.: type alias Model { page : Int } view model = case model.page of 0 -> viewA 1 -> viewB ... In my 'update' function I will set this pages: init : (Model, Cmd Action) init = let model = Model 0 in (model, Cmd.batch []) update action model = case action of ActionA -> model ! [ saveEntity ] SaveE (Err _) -> model ! [] SaveE (Ok _) -> { model | page = 1 } ! [] I have a button which triggers ActionA and this sends a backend-call. So sometimes it works as expected and sometimes the whole page will be reloaded after SaveE (Ok _) and the init function will be called and my model is initialized with the starting values. The backend gets some values and saves the entity in the db. This works fine with a curl-call. So my question is, is there a trigger which reloads the page and calls the init function? And has someone an idea why the init function will called in the middle of a flow? My problem is it seems that this happens randomly and I have currently no idea where the problem comes from. thx \= odi -- 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.
[elm-discuss] Randomly call init function
I have a strange (for me) behaviour in my flow. I have a backend call in which some entity will be saved. I have a page redirect logic e.g.: type alias Model { page : Int } view model = case model.page of 0 -> viewA 1 -> viewB ... In my 'update' function I will set this pages: update action model = case action of ActionA -> { model | page = 0 } ! [ saveEntity ] SaveE (Err _) -> model ! [] SaveE (Ok _) -> { model | page = 1 } ! [] I have a button which triggers ActionA and this shows the viewB. So sometimes it works as expected and sometimes the whole page will be reloaded and the init function will be called and my model is initialized with the starting values. The backend gets some values and saves the entity in the db. This works fine with a curl-call. So my question is, is there a trigger which reloads the page and calls the init function? My problem is it seems that this happens randomly and I have currently no idea where the problem comes from. thx \= odi -- 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.