Streamline typed actions and React-like component APIs - #6
Open
tiye wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces on_action_click(...) / on_action_enter(...) as small helper listeners to dispatch typed domain actions without repeating forwarding closures at component call sites, and updates demos + tests + docs to match the new convention.
Changes:
- Add
on_action_clickandon_action_enterhelpers in the core listener utilities (explore/react/state.kk). - Refactor Todo, Lab, and Route components to use the new helpers instead of
fn(owner) dispatch(action, owner)forwarding closures. - Add a focused test case covering typed action dispatch via click + Enter, and update documentation to describe when to use
on_action_*vson_local_*.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents on_action_click/on_action_enter as the preferred typed domain-action listener helpers. |
| PLAN.md | Updates the plan to capture the “typed domain-action listeners” convention and API surface. |
| explore/react/state.kk | Adds on_action_click / on_action_enter wrappers over on_local_* to reduce boilerplate. |
| demo/todo/view.kk | Replaces domain-action forwarding closures with on_action_* in Todo UI events. |
| demo/lab/view.kk | Replaces domain-action forwarding closures with on_action_* in Lab UI events. |
| demo/routebar.kk | Switches route navigation buttons to dispatch a typed route_action via on_action_click. |
| demo/model.kk | Adds dispatch_route_action and routes click payload handling through decode_route_action. |
| demo/tests/statecases.kk | Adds typed_action_listener_test to cover click + Enter typed action dispatch registration/execution. |
| demo/tests.kk | Registers the new typed action listener test in the overall demo test suite. |
| Agents.md | Documents the new convention to prefer on_action_* for domain actions and keep on_local_* for custom logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
app_view vnode; the app now installs one component runtime instead of merging feature runner tuplesfeature_root(group, key) { ... },component(group, key) { ... }, keyedcomponents(...), and the reusablecomponent_effect<s,e>capability alias(state, dispatch) = use_store(spec, initial = ...)form and route UI/domain changes through typedon_store_*/on_action_*listenerskey; propagate it through Todo/Lab store coordination and derive isolated listener, effect, VDOM, and DOM-marker identitiesBreaking API changes
vnodedirectly;run_todo_panel,run_lab_panel, and the runner adapter modules are removedcomponent_in(...)is renamed tocomponent(...); persistent absolute roots usefeature_root(...)reset_feature(...)replaces the misleadingreset_component(...)lifecycle nameuse_store(...)returns a(state, dispatch)pair instead of a binding recordValidation
yarn test:koka: 62 / 62 passedyarn buildyarn checkgit diff --checkleft,right, and default scopesDesign note
Algebraic effects remain the implementation mechanism for component scope, state, listeners, scheduled effects, and host capabilities. Persistence and agent-facing replay stay action/store concerns: domain and component actions remain typed inside Koka, while only versioned serializable state/actions cross the dynamic runtime boundary.