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.

Reply via email to