A global event trigger for Go that allows defining functions as events with string IDs and triggering them from anywhere in a project.
Go Trigger is a Go library that implements a global event triggering system, allowing developers to register functions as events with string identifiers and invoke them from anywhere in their codebase. It solves the problem of tight coupling between components by enabling decoupled, event-driven communication. The library supports both synchronous and asynchronous event firing, parameter passing, and return value handling.
Go developers building applications that require decoupled communication between modules, such as plugins, middleware, or event-driven architectures. It's particularly useful for those needing a simple, lightweight alternative to more complex message brokers or observer patterns.
Developers choose Go Trigger for its minimal API, thread safety, and flexibility—offering both global and local event scopes without external dependencies. Its ability to handle parameters, return values, and background execution makes it a versatile tool for event-driven workflows in Go.
A Global event triggerer for golang. Defines functions as event with id string. Trigger the event anywhere from your project.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Methods like trigger.On() and trigger.Fire() provide a minimal interface for defining and triggering events globally, enabling easy decoupled communication as shown in the basic usage examples.
Supports both global events and local trigger instances via trigger.New(), allowing for modular, isolated event systems without affecting global state, ideal for pluggable architectures.
FireBackground() runs events in goroutines for non-blocking task execution, demonstrated in the README with channel-based return value handling for background processing.
Built-in mutex locking ensures safe concurrent access to the event registry, making it suitable for multi-threaded Go applications without additional synchronization code.
Parameter and return value handling relies on reflection, requiring manual type conversion (e.g., values[0].Int()), which can introduce performance penalties and runtime type errors.
Each event currently supports only one handler, as noted under 'Under Development Features,' reducing flexibility for scenarios where multiple listeners or middleware are needed.
FireBackground() requires channel handling and careful coordination to prevent background events from terminating prematurely, adding complexity as warned in the README.