-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Refactor DispatchEvent to use enum for type-safety #403
Copy link
Copy link
Closed
Labels
type: featureBrand new functionality, features, pages, workflows, endpoints, etc.Brand new functionality, features, pages, workflows, endpoints, etc.
Description
Current Implementation
Currently, the DispatchEvent struct uses string-based event types:
pub struct DispatchEvent {
pub id: String,
pub name: String,
pub value: String,
pub timestamp: String,
}This approach has several drawbacks:
- No type safety for event types
- String comparison for event matching
- No structured data for specific event types
- Difficult to track all available event types
Proposed Change
Refactor DispatchEvent to use an enum for representing different event types:
pub enum EventType {
// Internal pre-defined events
UserTaskInit(String),
UserTaskUpdate(String),
// Other internal events...
// For custom events
Custom {
name: String,
value: String,
}
}
pub struct DispatchEvent {
pub id: String,
pub event_type: EventType,
pub timestamp: String,
}Benefits
- Type Safety: Compiler can enforce correctness for event handling
- Improved API: More intuitive API with proper type information
- Discoverability: All available event types visible in the enum
- Structured Data: Each event type can carry appropriate data
- Better IDE Support: Auto-completion for event types
Implementation Notes
- Update all places that create or consume events
- Maintain backward compatibility where needed
- Update documentation and tests
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: featureBrand new functionality, features, pages, workflows, endpoints, etc.Brand new functionality, features, pages, workflows, endpoints, etc.