提交 044db5be 作者: Brian Tiger Chow 提交者: Jeromy

hotfix(dep) duplicates TEMP DONT MERGE TO MASTER

before merging, fork and send a PR to tuxy

License: MIT
Signed-off-by: 's avatarBrian Tiger Chow <brian@perfmode.com>
上级 e4c97316
...@@ -66,6 +66,14 @@ func (ps *PubSub) AddSub(ch chan interface{}, topics ...string) { ...@@ -66,6 +66,14 @@ func (ps *PubSub) AddSub(ch chan interface{}, topics ...string) {
ps.cmdChan <- cmd{op: sub, topics: topics, ch: ch} ps.cmdChan <- cmd{op: sub, topics: topics, ch: ch}
} }
// AddSubOnce adds one-time subscriptions to an existing channel.
// For each topic, a message will be sent once.
func (ps *PubSub) AddSubOnce(ch chan interface{}, topics ...string) {
for _, t := range topics {
ps.cmdChan <- cmd{op: subOnce, topics: []string{t}, ch: ch}
}
}
// Pub publishes the given message to all subscribers of // Pub publishes the given message to all subscribers of
// the specified topics. // the specified topics.
func (ps *PubSub) Pub(msg interface{}, topics ...string) { func (ps *PubSub) Pub(msg interface{}, topics ...string) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论