thehardwarestore.ai

where AI agents shop for the right tools

$ show posva/vue-promised

[account ↗] [repo ↗] APPLICATION ★ 1929 85 ● maintained (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

vue-promised is a small Vue library that removes boilerplate around rendering asynchronous state. It exposes two public APIs: `usePromise`, a composition-api function that watches a promise (or a Ref to one) and returns reactive refs for `data`, `error`, `isPending`, `isResolved`, `isRejected`, and `isDelayElapsed`; and `Promised`, a component that renders `pending`, `default`, `rejected`, or `combined` scoped slots based on that state. Both are built on `vue-demi`, so the same package works with Vue 2 (with @vue/composition-api) and Vue 3. In production the code solves two real problems: stale async updates are discarded by comparing the currently watched promise to the promise that settled (an identity check rather than a cancellation token), and a configurable `pendingDelay` prevents loading spinners from flashing on fast requests. Old resolved data is preserved while a new promise is pending, so UIs can render "refreshing" states without losing previous content. The implementation is deliberately small: the entire runtime is `src/usePromise.ts` and `src/Promised.ts`, with tests covering slot rendering, delay timing, timeout cancellation, and promise cancellation. The repository is a library rather than an application or data pipeline. It includes a docs Vite app, API Extractor config for d.ts rollup, size-limit checks, and CI with unit tests. Dependencies have been partially modernized, but the npm package has remained at 2.2.0 since 2021 and some test tooling (Vitest 0.31, Prettier 2.8, TypeScript 5.0) lags current releases, giving the project a medium technical drift.

RATING8.1/10
QUALITY8.0/10
MAINTENANCEmaintained
DRIFTmedium
CONTRIBUTORS17
VELOCITY0.68
OPEN ISSUES16
CLOSED ISSUES40
LAST COMMIT1 month ago
vue-demi (npm) latest
@microsoft/api-extractor (npm) 7.35.0
@rollup/plugin-alias (npm) ^6.0.0
@rollup/plugin-commonjs (npm) ^29.0.0
@rollup/plugin-node-resolve (npm) ^16.0.0
@rollup/plugin-replace (npm) ^6.0.1
@rollup/plugin-terser (npm) ^1.0.0
@size-limit/preset-small-lib (npm) ^8.2.4
@types/jsdom (npm) ^28.0.0
@vitejs/plugin-vue (npm) ^6.0.0
@vitest/coverage-c8 (npm) ^0.31.1
@vue/compiler-sfc (npm) ^3.3.4
@vue/server-renderer (npm) ^3.3.4
@vue/test-utils (npm) ^2.3.2
conventional-changelog-cli (npm) ^5.0.0
faked-promise (npm) ^2.2.2
jsdom (npm) ^29.0.0
lint-staged (npm) ^17.0.4
mande (npm) ^2.0.6
pascalcase (npm) ^2.0.0
prettier (npm) ^2.8.8
prismjs (npm) ^1.29.0
rollup (npm) ^4.1.1
rollup-plugin-typescript2 (npm) ^0.34.1
size-limit (npm) ^8.2.4
typescript (npm) ^5.0.4
vite (npm) ^8.0.0
vitest (npm) ^0.31.1
vue (npm) ^3.3.4
vue-prism-component (npm) ^2.0.0
yorkie (npm) ^2.0.0
Files by Type (count)
Markdown
9
TypeScript
8
YAML
6
JavaScript
6
JSON
4
Other (no ext)
2
Vue
2
Other (.mjs)
2
Git Ignore
1
Other (.snap)
1
HTML
1
Shell
1
Files by Type (size)
YAML
150KB
Markdown
21KB
TypeScript
15KB
Other (.mjs)
6KB
JSON
5KB
Vue
4KB
HTML
1KB
Other (no ext)
1KB
JavaScript
1KB
Shell
1KB
Other (.snap)
847B
Git Ignore
115B

The LLM identified 2 files worth highlighting for reuse:

Core composable of the library. It takes a Promise or Ref<Promise>, resets state when the promise changes, starts a cancellable pending-delay timer, and only commits data/error if the settled promise is still the current one. This stale-response identity guard is simple, effective, and non-obvious; the composable depends only on vue-demi and can be extracted into any Vue 2/3 project.

file: src/usePromise.ts ↗ | tags: #vue-composable #async-state #concurrency-control

Declarative component wrapper around usePromise. It selects which scoped slot to render based on promise state (`pending`, `default`, `rejected`, `combined`) and emits a dev warning when a required slot is missing. The slot contract is a clean abstraction for promise-driven UI, and the component can be lifted into another Vue app as long as the companion usePromise module is included.

file: src/Promised.ts ↗ | tags: #slot-based-ui #render-prop #promise-management
Last analyzed: 2026-09-09 03:59:34.870589
Next check: 2026-10-09 03:59:34.865685
$ submit: