From 6e771641a62d26fef6546933a8a5fa2f1fa3177d Mon Sep 17 00:00:00 2001 From: Jason Axelson Date: Fri, 26 Aug 2022 21:39:54 -1000 Subject: [PATCH] Add set_reload_callback Provides an easy way to set the ExSync reload callback in a running system. Useful as a form of TDD-type development. --- lib/exsync.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/exsync.ex b/lib/exsync.ex index 2736b40..c39f633 100644 --- a/lib/exsync.ex +++ b/lib/exsync.ex @@ -2,4 +2,13 @@ require Logger defmodule ExSync do defdelegate register_group_leader, to: ExSync.Logger.Server + + @doc """ + Accepts a MFA and calls the MFA after every code change + + Useful for testing code in a tight feedback loop + """ + def set_reload_callback(module, function, argument) do + Application.put_env(:exsync, :reload_callback, {module, function, argument}) + end end