Decouple interaction events - #55
Conversation
Move per-element interaction handlers into the element table, keyed by ElementId, mirroring watches and bindings, and decouple them from the event queue. - Delete the standalone `Interactions` store (it was just a `TypeTable<ElementId>` wrapper); handlers now ride the element table as `HandlerFn<I, W>` components, one per `(element, I)`, dropped with the element via `remove_row`. - Decouple handlers from `Events`: a handler is now `fn(I, &mut W)` and mutates the world directly. `Fynix::dispatch` takes `&mut W` and the unused `events` field is removed. - Drop the now-dead `fynix_event` and `sparse_map` dependencies. - Add binding tests; fix the element-table component test to use the new `IdGenerator` helper.
- Rename `Watch` to `Watcher`
|
Warning Review limit reached
More reviews will be available in 44 minutes and 3 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR refactors fynix's runtime to be generic over a world type ChangesWorld-typed reactive runtime refactor
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Fynix
participant ElementTable
participant HandlerFn
participant Watcher
participant Binding
rect rgba(70, 130, 180, 0.5)
Note over Caller,HandlerFn: Interaction dispatch
Caller->>Fynix: dispatch(id, interaction, &mut world)
Fynix->>ElementTable: component::<HandlerFn<I,W>>(id)
ElementTable-->>Fynix: Some(handler)
Fynix->>HandlerFn: handler(interaction, &mut world)
HandlerFn-->>Caller: world mutated
end
rect rgba(60, 179, 113, 0.5)
Note over Caller,Binding: Reactive sync
Caller->>Fynix: sync(&mut world)
Fynix->>ElementTable: components::<Watcher<W>>()
loop each watcher where is_changed(world)
Fynix->>Watcher: rebuild(&id, fynix, world)
end
Fynix->>ElementTable: components::<Binding<W>>()
loop each binding where is_changed(world)
Fynix->>Binding: apply(&id, &mut elements, world)
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/fynix/src/reactive/binding.rs`:
- Around line 101-103: The doc comment for the function around lines 101-103
states that the element is "still marked dirty" on a no-op write when the
element is absent or of a different type, but this contradicts the actual
implementation where the function returns false in those cases and the apply()
method only marks the element dirty when success is true. Update the doc comment
to accurately reflect that no-op writes do NOT result in marking the element
dirty, removing the claim about marking dirty on absent or type-mismatch
scenarios.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c829da56-1060-4d9b-ae85-2e00a9a096ea
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (13)
crates/fynix/Cargo.tomlcrates/fynix/src/ctx.rscrates/fynix/src/element.rscrates/fynix/src/element/layout.rscrates/fynix/src/element/storage.rscrates/fynix/src/element/table.rscrates/fynix/src/interaction.rscrates/fynix/src/lib.rscrates/fynix/src/reactive.rscrates/fynix/src/reactive/binding.rscrates/fynix/src/reactive/watcher.rscrates/fynix_elements/src/lib.rscrates/fynix_hit_test/src/lib.rs
💤 Files with no reviewable changes (1)
- crates/fynix/Cargo.toml
Interaction handlers now take in
&mut Wworld as opposed to&mut Events.Eventsare meant to be opt-in, and can be used when the backend world does not have any event system at all.