Skip to content

feat(useRaf): add new composable#165

Merged
johnleider merged 3 commits intomasterfrom
feat/use-raf-clean
Mar 21, 2026
Merged

feat(useRaf): add new composable#165
johnleider merged 3 commits intomasterfrom
feat/use-raf-clean

Conversation

@johnleider
Copy link
Copy Markdown
Member

@johnleider johnleider commented Mar 21, 2026

Summary

  • Adds useRaf composable — scope-disposed safe requestAnimationFrame with cancel-then-request deduplication, automatic cleanup, and SSR safety
  • Backs isActive with shallowRef for true reactivity (matches createObserver/useToggleScope/useClickOutside precedent)
  • Adopts useRaf in SplitterHandle to replace manual RAF management
  • Includes docs page, scroll-throttle example, and 23 test cases

Test plan

  • 23 test cases: basic functionality, cancel-then-request, isActive state, cancel, reusability, scope disposal, error handling, SSR
  • All 3671 tests pass
  • Typecheck clean
  • Lint clean
  • Verify Splitter drag behavior in browser

…rame

- Cancel-then-request pattern deduplicates rapid RAF calls
- Automatic cleanup on scope disposal
- SSR-safe with isActive reactive state
- Documentation page with scroll-throttle example
isActive was derived via toRef from a plain let variable, so it had no
reactive dependency — watchers and templates couldn't track changes.
Replaced with shallowRef to match createObserver/useToggleScope precedent.

Refactored SplitterHandle to use useRaf instead of manual
requestAnimationFrame/cancelAnimationFrame management.
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 21, 2026

Open in StackBlitz

commit: f9b5313

@johnleider johnleider changed the title feat(useRaf): scope-safe requestAnimationFrame composable feat(useRaf): add new composable Mar 21, 2026
@johnleider johnleider merged commit aac766c into master Mar 21, 2026
12 of 14 checks passed
@johnleider johnleider deleted the feat/use-raf-clean branch March 21, 2026 19:34
@johnleider johnleider added this to the v0.1.x milestone Mar 28, 2026
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