aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/conf/storewatcher.go
blob: ffd20ee03f18eaaab34021b8b5a34c84ea340dfe (plain) (tree)
1
2
3
4
5
6
7
8
9
10






                                                         
                           

                 
 
                                                  
 
                                                            

                                
                               

                                

 
                                       
                                  
 
/* SPDX-License-Identifier: MIT
 *
 * Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
 */

package conf

type StoreCallback struct {
	cb func()
}

var storeCallbacks = make(map[*StoreCallback]bool)

func RegisterStoreChangeCallback(cb func()) *StoreCallback {
	startWatchingConfigDir()
	cb()
	s := &StoreCallback{cb}
	storeCallbacks[s] = true
	return s
}

func (cb *StoreCallback) Unregister() {
	delete(storeCallbacks, cb)
}