Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何实现自动保存,或者set回调以实现自动保存 #61

Closed
aadog opened this issue Feb 18, 2022 · 6 comments
Closed

如何实现自动保存,或者set回调以实现自动保存 #61

aadog opened this issue Feb 18, 2022 · 6 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@aadog
Copy link
Contributor

aadog commented Feb 18, 2022

如何实现自动保存,或者set回调以实现自动保存

@inhere inhere added the question Further information is requested label Feb 18, 2022
@inhere
Copy link
Member

inhere commented Feb 18, 2022

保存到文件吗?

@aadog
Copy link
Contributor Author

aadog commented Feb 19, 2022

大部分情况下都需要可写 有一个onset回调来写回缓存并保存文件 这个库实现很完美 唯独缺了这个 如果有手动保存模式和自动保存模式很好 单独的write太过繁琐了

@inhere inhere added the enhancement New feature or request label Feb 19, 2022
@aadog
Copy link
Contributor Author

aadog commented Mar 1, 2022

它有任何进度吗,或者需要我帮住吗,我也可以提交

@inhere
Copy link
Member

inhere commented Mar 1, 2022

暂时没有时间改进这个。你能发个PR最好了 👍

@inhere inhere closed this as completed in d9f66ad Apr 15, 2022
@inhere
Copy link
Member

inhere commented Apr 15, 2022

添加了一个简单的事件触发。可以看看:

在创建配置时添加钩子函数:

	hookFn := func(event string, c *Config) {
		fmt.Println("fire the:", event)
	}

	c := NewWithOptions("test", WithHookFunc(hookFn))
	// for global config
	config.WithOptions(WithHookFunc(hookFn))

之后, 当调用 LoadXXX, Set, SetData, ClearData 等方法时, 就会输出:

fire the: load.data
fire the: set.value
fire the: set.data
fire the: clean.data

@inhere inhere reopened this Apr 15, 2022
@aadog
Copy link
Contributor Author

aadog commented Apr 17, 2022

thanks

@inhere inhere closed this as completed Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants