Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor DispatchEvent to use enum for type-safety #403

Open
tusharmath opened this issue Feb 27, 2025 · 6 comments
Open

Refactor DispatchEvent to use enum for type-safety #403

tusharmath opened this issue Feb 27, 2025 · 6 comments
Labels
💎 Bounty enhancement New feature or request

Comments

@tusharmath
Copy link
Collaborator

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

  1. Type Safety: Compiler can enforce correctness for event handling
  2. Improved API: More intuitive API with proper type information
  3. Discoverability: All available event types visible in the enum
  4. Structured Data: Each event type can carry appropriate data
  5. 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
@tusharmath tusharmath added the enhancement New feature or request label Feb 27, 2025
@tusharmath
Copy link
Collaborator Author

/bounty $30

Copy link

algora-pbc bot commented Feb 27, 2025

💎 $30 bounty • Tailcall Inc.

Steps to solve:

  1. Start working: Comment /attempt #403 with your implementation plan
  2. Submit work: Create a pull request including /claim #403 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

🙏 Thank you for contributing to antinomyhq/forge!
🧐 Checkout our guidelines before you get started.
💵 More about our bounty program.

Attempt Started (GMT+0) Solution
🔴 @loop-index Feb 27, 2025, 9:17:59 AM WIP
🟡 @n0tank3sh Mar 1, 2025, 9:19:31 PM WIP

@tusharmath
Copy link
Collaborator Author

Call to Action: Build This with Forge! 🛠️

Hey everyone! This would be a great opportunity to use Forge itself to implement this feature. The proposed enum-based DispatchEvent refactoring is a well-scoped task that would demonstrate Forge's capabilities for code refactoring.

Challenge:

  1. Use Forge to help implement this enum-based refactoring
  2. Record your screen while doing it (showing how Forge helps you)
  3. Share the recording - whether it works perfectly or encounters interesting challenges!

Why record?

  • Success stories help us showcase Forge's strengths
  • Challenges help us identify areas for improvement
  • Real usage examples are invaluable for our development process

Tips for recording:

  • Focus on your interaction with Forge
  • Narrate your thought process as you go
  • Don't worry if everything isn't perfect - real-world usage is what we want to see

Who's up for the challenge? 🚀

@loop-index
Copy link

loop-index commented Feb 27, 2025

/attempt #403

Copy link

algora-pbc bot commented Mar 1, 2025

The bounty is up for grabs! Everyone is welcome to /attempt #403 🙌

Copy link

algora-pbc bot commented Mar 2, 2025

@n0tank3sh: Reminder that in 1 days the bounty will become up for grabs, so please submit a pull request before then 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants