Skip to content

Commit

Permalink
Try passing callback via a ref
Browse files Browse the repository at this point in the history
  • Loading branch information
actionshrimp committed Apr 17, 2018
1 parent 030f0b4 commit f7ba4c9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/backend_osx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f7ba4c9

Please sign in to comment.