From f18e61449aba4c3d98e1f55b13c139fa482cb5dd Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Sat, 29 Aug 2015 20:36:27 +0300 Subject: [PATCH] Add init helper --- secondly.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/secondly.go b/secondly.go index d552ace..5d6fcd7 100644 --- a/secondly.go +++ b/secondly.go @@ -21,6 +21,7 @@ var ( configFile string callbacks = make(map[string][]func(oldVal, newVal interface{})) initialized bool + initFunc func() ) // SetupFlags sets up Confection configuration flags. @@ -96,6 +97,12 @@ func HandleFSEvents() { }() } +// OnLoad sets up a callback function that would be called once configuration +// is loaded for the first time. +func OnLoad(fun func()) { + initFunc = fun +} + // OnChange adds a callback function that is triggered every time a value of // a field changes. func OnChange(field string, fun func(oldVal, newVal interface{})) {