Run with iocaml -js full <notebook>
Lwt in the browser. The code doesn't lock up the browser while it's running.
In [1]:
let rec f i =
if i=10 then Lwt.return ()
else
Lwt.(return (Iocaml.send_clear ~stdout:false ();
Printf.printf "hello stdout %i\n" i;
Printf.fprintf stderr "hello stderr %i\n" i)
>>= fun () -> Lwt_js.sleep 0.5
>>= fun () -> f (i+1))
Out[1]:
In [2]:
f 0
Out[2]: