package bus

// EventHandler 事件处理函数
type EventHandler func(BusEvent)

// Subscription 订阅句柄
type Subscription struct {
	bus       *ConversationBus
	eventType EventType
	handler   EventHandler
}

// Unsubscribe 取消订阅
func (s *Subscription) Unsubscribe() {
	if s.bus != nil {
		s.bus.unsubscribe(s)
	}
}

// NopBus 空操作总线（用于 nil 安全和测试）
type NopBus struct{}

func (n *NopBus) Publish(event BusEvent) {}
func (n *NopBus) Subscribe(eventType EventType, handler EventHandler) *Subscription {
	return &Subscription{}
}
func (n *NopBus) unsubscribe(sub *Subscription) {}
