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

custom Event not work #72

Closed
binary4cat opened this issue May 23, 2019 · 4 comments
Closed

custom Event not work #72

binary4cat opened this issue May 23, 2019 · 4 comments

Comments

@binary4cat
Copy link

Hi, I Have a custom event listen for config file changes, but it not work, can you help me ?

package main

import (
	"fmt"
	"github.com/go-chassis/go-archaius"
	"github.com/go-chassis/go-archaius/core"
)
type Listener struct {
	Key string
}
func (e *Listener) Event(event *core.Event) {
	//  I want to dynamically get the latest values here.
	fmt.Printf("****************%v",event)
}
func main(){
	archaius.Init(archaius.WithRequiredFiles([]string{
		"./test.yaml",
	}))
	select{}
}

I want to get real-time changed values via Event function , but it didn't do anything, what do I need to do to make it work?

@tianxiaoliang
Copy link
Member

you didn't register it. plz check example again

@binary4cat
Copy link
Author

I refer to https://github.com/go-chassis/go-archaius/blob/master/examples/event/event.go to achieve, How should I register it in this example?

@tianxiaoliang
Copy link
Member

func RegisterListener(listenerObj core.EventListener, key ...string) error {

@binary4cat
Copy link
Author

Thanks a lot for you, But why not add this RegisterListener to the event example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants