messages

package
v0.0.0-...-a33f2fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2023 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MessageRegistry *hashmap.Map[string, *hashmap.Map[string, func(name, id string, args interface{})]] = hashmap.New[string, *hashmap.Map[string, func(name, id string, args interface{})]]()

Functions

func Register

func Register(name string, id string, handler func(name, id string, args interface{}))

Register your message handler with the message system. Name is the lookup name for the message, id is a free text field that you can use to identify your handler, and handler is the function that will be called when the message is sent.

There can be as many handlers as you want for a message. The id is used to identify the handler, so you can remove it later. Registering another handler with the same id will replace the old handler.

func SendMessage

func SendMessage(name string, args interface{})

Send a message. The name is the lookup name for the message, and args is the data to be sent to the handler. Sendmessage calls the handler immediately (i.e. synchronously)

func Unregister

func Unregister(name string, id string)

Delete a handler. The name and id must be the same as the ones used to register the handler.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL