Skip to content

refactor: move EventTarget to internal package#855

Draft
tonyfettes wants to merge 1 commit intomainfrom
haoxiang/event-target
Draft

refactor: move EventTarget to internal package#855
tonyfettes wants to merge 1 commit intomainfrom
haoxiang/event-target

Conversation

@tonyfettes
Copy link
Contributor

Motivation

Packages other than agent needs to emit/receive their own event too, for example:

  • cmd/test, for emitting system informations like model, system prompt
  • cmd/server and cmd/daemon, for emitting synchronization event, status event, etc. See daemon_test.mbt and server_test.mbt on more detail on their customized event other than events emitted from agent.

Therefore, if we could generialize the underlying emit/add_listener mechanism, we can use the same data structure across all these packages, improving the uniformity of coding style, reducing code duplication.

Changes

This PR extract the "pure control flow" part of the logic from @event.EventTarget, and place it into internal/event_target, and thus making it a generic type EventTarget[T] where T is anything that consumer may want to passing around using such data structure.

This refactor does not directly remove the @event.EventTarget, but instead making it a simple wrapper over @internal/event_target.EventTarget[Event] to provider easier event emitting, etc.

@tonyfettes tonyfettes marked this pull request as draft December 17, 2025 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant