From f7ba4c9a67a02c22de7e115c26d253458a731a62 Mon Sep 17 00:00:00 2001 From: Dave Aitken Date: Tue, 17 Apr 2018 11:13:21 +0100 Subject: [PATCH] Try passing callback via a ref --- src/backend_osx.ml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/backend_osx.ml b/src/backend_osx.ml index 751764e..8b2d445 100644 --- a/src/backend_osx.ml +++ b/src/backend_osx.ml @@ -15,16 +15,15 @@ let make_watcher let stream = Fsevents_lwt.stream watcher in let run_loop_mode = Cf.RunLoop.Mode.Default in - let cb_f event = + let cb_f = ref (fun event -> (* TODO: handle path mapping back to server path *) let local_path = event.Fsevents_lwt.path in debug_log_lwt (Printf.sprintf "[livereload (osx-fsevents)] %s%!" local_path) >>= fun _ -> change_cb local_path >>= fun _ -> - Lwt.return () - + Lwt.return ()) in - Lwt.async (fun () -> Lwt_stream.iter_s cb_f stream); + Lwt.async (fun () -> Lwt_stream.iter_s !cb_f stream); Cf_lwt.RunLoop.run_thread (fun runloop -> Fsevents.schedule_with_run_loop event_stream runloop run_loop_mode;