Skip to content

feat(ui): expose use_xxx() factory API for 8 hook primitives and add 4 example pages - #40

Merged
eastspire merged 2 commits into
masterfrom
feat/ui-hook-api-and-demos-2026-08-28
Aug 28, 2026
Merged

feat(ui): expose use_xxx() factory API for 8 hook primitives and add 4 example pages#40
eastspire merged 2 commits into
masterfrom
feat/ui-hook-api-and-demos-2026-08-28

Conversation

@eastspire

Copy link
Copy Markdown
Collaborator

Summary

Wire the eight previously headless euv-ui hook primitives to actual public API surfaces (use_xxx() factories + Copy + R2.1 ///) and add four demonstration pages (hooks-timing / hooks-async / hooks-protect / hooks-i18n) so the example project consumes them end-to-end. Bump the workspace to 0.17.0 (minor) since this PR adds new public functions to the euv-ui crate.

Part 2 of the user's "complete the missing components and hooks" series — Part 1 (PR #39) already added the missing /// summaries on R2.1-critical impl blocks; this PR finishes the job by exposing the factory functions the doc-comments already advertise.

What landed

A. euv-ui hook-layer public API surface

Hook New factory Visibility bump Doc comment added
use_debounced_value::<T>(delay_ms: u32) pub fn in hook/debounced_value/fn.rs DebouncedValue<T>: Copy (impl) /// on the new impl block
use_throttled_value::<T>(interval_ms: u32) pub fn in hook/throttled_value/fn.rs ThrottledValue<T>: Copy (impl) /// on the new impl block
use_previous::<T>() + previous_step(...) pub fn in hook/previous/fn.rs Previous<T>: Copy (impl) /// on the new impl block
use_lazy_component::<T, F>(factory: F) pub fn in hook/lazy/fn.rs (already Clone) /// on the new impl block
use_suspense::<T>() pub fn in hook/suspense/fn.rs SuspenseHandle<T>: Copy (impl) /// on the new impl block
use_error_boundary() pub fn in hook/error_boundary/fn.rs (extracted from the helper that the existing impl block needs) ErrorBoundary: Copy (impl) /// on the new impl block
use_profiler() + profiler_measure(label, body) pub fn in hook/profiler/fn.rs (with the now_ms pub fn js-sys wrapper that the impl already expected) ProfilerHandle: Copy (impl) /// on the new impl block
use_i18n(init_locale) + i18n_register(handle, locale, &[(&'static str, &'static str)]) + interpolate(template, vars) (the existing impl needed but was never defined) pub fn + pub(crate) fn in hook/i18n/fn.rs I18n: Copy (impl) /// on the new impl block
use_async::<T, L>() (uses the existing UseAsyncHandle::new_for_fallback path; HookContext::use_async is on the roadmap but does not exist in euv-core yet) pub fn in hook/use_async/fn.rs UseAsyncHandle<T, L>: Copy (impl) /// on the new impl block

Plus:

  • ProfilerHandle::new_with_empty_entries() — hand-written because Lombok New cannot synthesise the default Signal<...> field.
  • #[get(type(copy))] on DebouncedValue::value and ThrottledValue::value so the call site can read the emitted value through a Copy boundary instead of borrowing.
  • All eight mod.rs files updated to the rust-standards three-section shape: mod r#fn; (where applicable) + pub use {r#fn::*, ...} + trailing use super::*;.
  • error_boundary/mod.rs re-exports extract_message and use_error_boundary at the visibility the rest of the crate expects.

B. Example demo pages (4 new pages, 29 → 33)

Each page lives in example/src/page/hooks_{timing,async,protect,i18n}/, with mod.rs + hook/{fn,mod}.rs + view/{fn,struct,mod}.rs mirroring the existing page template (per euv-ui-standards §8).

Route Consumes Demo
/hooks-timing use_debounced_value + use_throttled_value + use_previous Live input debounce / throttle parallel display, plus a "previous-render snapshot" row
/hooks-async use_async + use_lazy_component + use_suspense AsyncState toggle / lazy load / suspend-resolve-fail-reset trio
/hooks-protect use_error_boundary + use_profiler Panic capture / measurement log
/hooks-i18n use_i18n English / Chinese locale switch with the same two keys

view/fn.rs correctly applies the R2.1 /// doc-comment contract on every fn and impl block.

C. Navigation + routing registration

example/src/component/nav/view/const.rs gets four new NAV_ITEMS rows; example/src/component/router/view/fn.rs gets four new match arms; example/src/page/mod.rs adds the four new modules and exports.

Verification

cargo check -p euv-ui
cargo check -p euv-example
cargo check -p euv-example --target wasm32-unknown-unknown
euv fmt

The audit_rust_standards 14-item suite remains 100% green; the targeted R2.1 scan (fn + impl regex + "block immediately above has ///") reports Missing fn /// = 0, Missing impl /// = 0 across ui/src after this change.

Versioning

Workspace bumps from 0.16.1 to 0.17.0 (minor). New pub functions are added but no existing signature changes / breaks — patch bump would technically suffice, but the 0.16.x series was the "docs compliance + new example pages" rollout; 0.17.0 matches the new pub-surface.

Per project memory: CI's sync_workspace_version job propagates the root bump, publish job pushes the crate to crates.io, release job cuts the git tag + GitHub Release. No manual intervention needed on those steps once the PR merges into master.

Scope / non-goals

  • HookContext::use_*() methods are not added — that lives in euv-core, which this PR deliberately leaves untouched.
  • App::use_*() wrappers in euv-core are not added — same reason.
  • The form, transition, i18n HookContextExt impls remain exactly as upstream ships them. New use_xxx factories in euv-ui are the public-API alternative that already works today.
  • No Cargo.toml formatting change other than the version bumps. taplo fmt was not run (no rule requires it for a Cargo.toml lines-only edit).

Followup (out of scope)

  • HookContext::use_async(T, L, factory) is the natural next step — it would replace the new_for_fallback() path that use_async currently relies on. That requires an euv-core change.
  • HookContext::use_form, use_i18n, use_transition already exist but currently route through their HookContextXxxExt traits; the new use_xxx factories in euv-ui are independent and additive.

@eastspire
eastspire force-pushed the feat/ui-hook-api-and-demos-2026-08-28 branch 4 times, most recently from 24a8526 to 7b61330 Compare August 28, 2026 15:04
@eastspire
eastspire force-pushed the feat/ui-hook-api-and-demos-2026-08-28 branch from 7b61330 to ecc9920 Compare August 28, 2026 15:18
@eastspire
eastspire merged commit 201d455 into master Aug 28, 2026
@eastspire
eastspire deleted the feat/ui-hook-api-and-demos-2026-08-28 branch August 28, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant