refactor: replace string-based emitter with type-safe generic event system
Refactors the event emitter system from string-based messages to a type-safe generic implementation using typed events. Consolidates separate tracker packages into a unified plugins architecture. Changes: - Replace Emitter with BaseEmitter[E comparable] using generics - Add Event type with StartEvent, StepEvent, and StopEvent constants - Create Listener[E] interface with BaseListener implementation - Consolidate explanation, performance, and statistics trackers into internal/plugins package - Simplify main CLI by using plugin constructors instead of manual event subscription - Add Items() iterator method to Set for idiomatic range loops
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
type Engine struct {
|
||||
Config *config.Config
|
||||
Expression *lambda.Expression
|
||||
emitter.Emitter
|
||||
emitter.BaseEmitter[Event]
|
||||
}
|
||||
|
||||
// Create a new engine, given an unreduced λ-expression.
|
||||
@@ -22,11 +22,11 @@ func New(config *config.Config, expression *lambda.Expression) *Engine {
|
||||
|
||||
// Begin the reduction process.
|
||||
func (e Engine) Run() {
|
||||
e.Emit("start")
|
||||
e.Emit(StartEvent)
|
||||
|
||||
lambda.ReduceAll(e.Expression, func() {
|
||||
e.Emit("step")
|
||||
e.Emit(StepEvent)
|
||||
})
|
||||
|
||||
e.Emit("end")
|
||||
e.Emit(StopEvent)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user