Post-update invariant repair: good idea or bad?

I think that pattern is fine, we used it for a while for our analytics as well but up at the top of the app, the update function for our analytics would get the message, the old model, and the new model and could send off commands.

The only caveat is that with sorting the items on each Msg it will prevent using Html.lazy with it because it is a new reference each time, you’d have to check if the list is already sorted and return the existing model to let lazy rendering work.

One thing I might change is storing the data in a Dict and then keeping a separate list that had the Ids of the items in a sorted order, then the view function uses that sorted list and the Dict lookup.

1 Like