Closed ethanabrooks closed 7 years ago
This seemingly weird behavior is due to "call buffering". As of version 0.8, Threepenny will buffer JavaScript FFI calls and only send them to the browser when necessary. You can flush the buffer by hand (flushCallBuffer
) or change to a different buffering mode. In this case, the beat
function will flush the buffer (get UI.checked
will do that).
In the next release, v0.8.1, I intend to improve the documentation and make onEvent
flush the call buffer, so this confusion appears less often.
See also #163, #191, #192 .
Perfect! Adding flushCallBuffer
after line 51 solved the problem. How does one change to a different buffering mode, as you suggested?
setCallBufferMode
Ok. Makes sense. Thank you.
I have been playing around with DrumMachine.hs and I plan to adapt it to a project I am working on. I was hoping you could help me understand why, if line 53 --
sequence_ $ map (!! beat) kit
-- is commented out, the 'beat: ' number doesn't update on the resulting webpage. It seems like the only thing that line should do is actually play the sound. It shouldn't affect the number being changed on the screen.