Closed whidbey closed 8 years ago
What exactly did you try? Specifically if you have sample code that illustrates your attempt, that would be helpful
package a s:=new eventbus s.subsribe("some",funcs); package b s2:=new eventbus s2.pub(“some")
dont work.
package a var s eventbus func Pass(x eventbus){ s=x; } s.subsribe("some",funcs); package b s2:=new eventbus a.Pass(s2) s2.pub(“some")
works.
I think this is a non-issue, more of a misunderstanding.
In your 1st example, you have created 2 event buses. Each time you call EventBus.New(), it creates a new EventBus with a new state.
If you want to ensure you only ever use the same instance of the EventBus across multiple packages, you can declare an EventBus as an exported variable of the package.
Alternatively, see this example:
Feel free to correct me if I am wrong.
you are right,thats what exactly needs.great and thank you
I try but fail.