|
I've been toying around with Elm lately and it's my first introduction to FP-style programming. I'm working on making a very basic Cookie Clicker clone to practice with Signals, but I'm hung up on how I should merge my model update (i.e. increment by 1) on both: a) every click (already have this handled as an onClick in a View element) and b) every 1 second that passes. These actions are doing the same thing, so where would I add in a Signal handler to perform the "Increment" action every 1 second? Would it be a foldp or Signal.map that I'm thinking too hard about?
|
# ¿ Jan 16, 2016 06:42 |
|
|
# ¿ Apr 29, 2024 09:48 |
|
fart simpson posted:Post some code? The answer is probably to Signal.map your input signals into an Increment action and merge them, then foldp the resulting action signal Game model just defines clicks, level, and cps_multiplier. code:
|
# ¿ Jan 16, 2016 07:22 |
|
fart simpson posted:Try this, is it what you want? You basically just pass the mapped Increment action from the every second signal into the inputs field of the StartApp config Perfect! I was about to post back with something similar (using input=[]). Is there a resource you have that explains why Effects.Effects needs to be used when dealing with this kind of signal? Is it because the ticker is constantly running?
|
# ¿ Jan 16, 2016 08:09 |