Closed murtaza52 closed 10 years ago
(copy-pasted from mailing list):
Thanks!
If you wanted to, you could simply use two atoms for weight/height, and a simple function calculates the bmi on the fly from them – that would work as in the Hoplon example.
But you probably don't want that :)
With a map in a single atom you get more flexibility. For example: my little demo allows you to change also the bmi parameter, and have the weight change correspondingly, as well as the other way around.
And in general, it probably will be easier to make sure that your data is consistent if you keep state that belongs together, together...
I am fine with keeping the state together in a map. No problems there.
However what I want is to change the parameter (weight, height etc), and force that to trigger the evaluation of the bmi. This is in contrast to explicitly recalculating the bmi, when any parameter changes.
Thanks, Murtaza
On Mon, Jan 13, 2014 at 9:30 PM, holmsand notifications@github.com wrote:
(copy-pasted from mailing list):
Thanks!
If you wanted to, you could simply use two atoms for weight/height, and a simple function calculates the bmi on the fly from them – that would work as in the Hoplon example.
But you probably don't want that :)
With a map in a single atom you get more flexibility. For example: my little demo allows you to change also the bmi parameter, and have the weight change correspondingly, as well as the other way around.
And in general, it probably will be easier to make sure that your data is consistent if you keep state that belongs together, together...
— Reply to this email directly or view it on GitHubhttps://github.com/holmsand/cloact/issues/3#issuecomment-32182146 .
The BMI calculator example here
http://holmsand.github.io/reagent/
has now been tweaked to only do the calculation when the component is re-rendered, which may be more what you are after. This is also now slightly more efficient in Reagent than re-calculating when parameters change (not that it makes any difference whatsoever in this simple example, but anyway...), since Reagent now updates the UI asynchronously.
Hi,
(Reposting it here from cljs list)
Thanks for cloact, its great !
I was comparing the BMI Calculator from hoplon and cloact, and could see that the hoplon approach was more simpler for one primary reason - their use of FRP (javelin) to tie in the model pieces.
So when a user change occurs, instead of calling change-bmi, the hoplon example simply changes the weight/height. This causes the respective bmi to change, which causes the ui to rerender.
Cloact currently uses an atom to propogate state changes, is it possible to swap it with the javelin implementation ?
Thanks, Murtaza