You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#147 feat: add automatic cleanup for EventHandle via Drop trait (#151)
Implement RAII pattern for event handler cleanup to prevent memory leaks:
- Add Drop impl for EventHandle that automatically unregisters callbacks
- Add unregistered flag to prevent double cleanup
- Log errors during automatic cleanup instead of panicking
- Update EventHandle documentation with automatic cleanup examples
This eliminates the need for manual cleanup in most cases:
- Event handlers automatically unregister when handle drops
- Prevents memory leaks from forgotten callbacks
- Prevents stale callbacks executing after component destruction
- Still supports manual cleanup via off_event() if needed
Benefits:
- Idiomatic Rust lifecycle management
- Follows RAII principles
- Simplifies framework integration (Yew, Leptos)
- All existing tests pass (208 tests)
0 commit comments