Introduce lazy API resource activation (lazyApiResource + LazyResource)#2201
Introduce lazy API resource activation (lazyApiResource + LazyResource)#2201
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
UI unit Tests 1 files ± 0 3 suites - 51 0s ⏱️ -25s Results for commit f82c026. ± Comparison against base commit 3f62d45. This pull request removes 140 and adds 10 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Motivation
Description
LazyResourceclass inproject/lazy-resource.tswhich wraps arunedResourceReturnand only activates the underlying resource on firstcurrentread orrefetchcall.lazyApiResourcetoProjectContextinproject/project-context.svelte.tswhich composes arunedresource with an activation gate (LazyActivation) and returns aLazyResourcethat triggers the API factory on demand;apiResourcenow defaults tolazywhen API is not yet available.parts-of-speech.svelte.tsto uselazyApiResourceso parts-of-speech are not fetched until needed.ShadcnProjectView.svelteto register the parts-of-speech service in project scope without forcing load.LazyApiResourceHarness.sveltetest helper used by tests.lazy-resource.test.tsandlazy-api-resource.browser.test.tsthat verify activation semantics and lazy fetch behavior.Testing
vitestunit tests includinglazy-resource.test.ts, which passed.lazy-api-resource.browser.test.ts(via the test harness), which passed and confirmed the API factory is not called on initialization and that data is loaded after the firstcurrentread.Codex Task