Re: [elm-discuss] Best practices for designing models in the Elm Architecture - lean or rich?

2017-08-01 Thread John Bortins
Ha! I just stumbled onto this recently to solve an ugly performance issue and it works great. The cost is a layer of complexity added to the update function. In this way, the intermediate calculations need be done just once per update rather than spread out many times over the view. Well worth

Re: [elm-discuss] Best practices for designing models in the Elm Architecture - lean or rich?

2017-07-25 Thread Ray Toal
Great tip, thanks! On Tuesday, July 25, 2017 at 12:50:20 AM UTC-7, Christian Charukiewicz wrote: > > In your expensive function example, you should be able to take advantage > of Html.Lazy to prevent the view from re-running the expensive function > unless its parameters change. By storing the

Re: [elm-discuss] Best practices for designing models in the Elm Architecture - lean or rich?

2017-07-25 Thread Christian Charukiewicz
In your expensive function example, you should be able to take advantage of Html.Lazy to prevent the view from re-running the expensive function unless its parameters change. By storing the derived data in the model rather than letting Elm handling the caching through the Lazy functions, you ar

Re: [elm-discuss] Best practices for designing models in the Elm Architecture - lean or rich?

2017-07-25 Thread Peter Damoc
Keep derived data in the model if it makes sense to keep derived data in the model. If you have an expensive function that runs and computes a derived value and you would have to call frequently this function in your view, then by all means, computer the derived value in update and save it in the

[elm-discuss] Best practices for designing models in the Elm Architecture - lean or rich?

2017-07-24 Thread Ray Toal
This might be an opinion-based question so I can't ask it on StackOverflow. :-) I have a trivial beginnerProgram using the Elm Architecture. It has two text fields (HTML input elements), one for weight and one for height. The onInput attributes of each generate a message. The update function ac