OvermindDL1 / bucklescript-tea

TEA for Bucklescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question - mutation during update?

dlants opened this issue · comments

I was about to use an Array for a part of my model, and using Belt.Array.set as part of the update. I am worried that the TEA implementation that this is based on assumes that you're dealing with immutable arrays, like the ones built into elm.

Is bucklescript-tea robust to mutating the model in the update function? Or should we avoid using mutation and rely on immutable data structures?

Thanks!

Correct, you do not want to mutate anything in your model unless you are very very careful with what you are doing. The renderer runs out-of-band and thus you can get surprising results at times.

However, you can do it if you just keep the above in mind and write the view in such a way to expect that, which honestly most views by default will be. :-)

However, mutating the model breaks time travel debugging via that addon, so if that is important then you don't want to mutate anyway, but if you aren't going to use it then that is not an issue either. :-)

As far as this library is concerned it doesn't care what is in your model or how it is used though, that's all on your code. ^.^

Feel free to ask any more questions here, just closing it to keep it cleaner. :-)