package
module
Version:
v0.0.3
Opens a new window with list of versions in this module.
Published: Apr 23, 2022
License: MIT
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
UHub
universal subscriber and publisher
package main
import (
"fmt"
"github.com/coreservice-io/UHub"
)
const testKind UHub.Kind = 1
type testEvent string
func (e testEvent) Kind() UHub.Kind {
return testKind
}
func main() {
var h UHub.Hub
h.Subscribe(testKind, func(e UHub.Event) {
fmt.Println("subcallback")
fmt.Println(string(e.(testEvent)))
})
h.Publish(testEvent("this is example"))
}
Documentation
¶
type Event interface {
Kind() Kind
}
Publish an event to the subscribers.
func (h *Hub) Subscribe(kind Kind, f func(Event)) (cancel func())
Subscribe registers f for the event of a specific kind.
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.