{"id":13435095,"url":"https://github.com/posva/vue-compose-promise","last_synced_at":"2025-09-11T06:31:35.163Z","repository":{"id":143925525,"uuid":"210888758","full_name":"posva/vue-compose-promise","owner":"posva","description":"💝 Promises using vue composition api","archived":false,"fork":false,"pushed_at":"2020-11-16T22:44:39.000Z","size":116,"stargazers_count":76,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-27T15:15:54.360Z","etag":null,"topics":["composition","promise","vue","vue-composition-api","vue-function-api"],"latest_commit_sha":null,"homepage":"https://codesandbox.io/s/vue-compose-promise-example-toum7","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/posva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/funding.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"posva","custom":"https://www.paypal.me/posva"}},"created_at":"2019-09-25T16:15:43.000Z","updated_at":"2023-03-15T05:46:19.000Z","dependencies_parsed_at":"2024-01-15T17:39:20.632Z","dependency_job_id":"e4611f90-ee1e-494e-a62a-32aba92dc980","html_url":"https://github.com/posva/vue-compose-promise","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posva%2Fvue-compose-promise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posva%2Fvue-compose-promise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posva%2Fvue-compose-promise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posva%2Fvue-compose-promise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posva","download_url":"https://codeload.github.com/posva/vue-compose-promise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232615200,"owners_count":18550648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composition","promise","vue","vue-composition-api","vue-function-api"],"created_at":"2024-07-31T03:00:32.430Z","updated_at":"2025-01-05T16:51:26.866Z","avatar_url":"https://github.com/posva.png","language":"TypeScript","funding_links":["https://github.com/sponsors/posva","https://www.paypal.me/posva"],"categories":["✨ Composition API functions","Packages"],"sub_categories":[],"readme":"# Use [Vue Promised](https://github.com/posva/vue-promised) instead\n\nIt supports Vue 2 and Vue 3\n\n---\n\n# vue-compose-promise [![Build Status](https://badgen.net/circleci/github/posva/vue-compose-promise)](https://circleci.com/gh/posva/vue-compose-promise) [![npm package](https://badgen.net/npm/v/vue-compose-promise)](https://www.npmjs.com/package/vue-compose-promise) [![coverage](https://badgen.net/codecov/c/github/posva/vue-compose-promise)](https://codecov.io/github/posva/vue-compose-promise) [![thanks](https://badgen.net/badge/thanks/♥/pink)](https://github.com/posva/thanks)\n\n\u003e Easily manipulate Promises and their state in Vue\n\n**Depends on [@vue/composition-api](https://github.com/vuejs/composition-api)**\n\n[CodeSandbox demo](https://codesandbox.io/s/vue-compose-promise-example-toum7)\n\n## Installation\n\n```sh\nnpm install vue-compose-promise\n```\n\n## Usage\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv\u003e\n    \u003cspan\u003e Is the promise still pending: {{ usersPromise.isPending }} \u003c/span\u003e\n    \u003cspan\u003e Is the 200ms delay over: {{ usersPromise.isDelayOver }} \u003c/span\u003e\n    \u003cspan\u003e\n      Last successfully resolved data from the promise: {{ usersPromise.data }}\n    \u003c/span\u003e\n    \u003cspan\u003e Error if current promise failed: {{ usersPromise.error }} \u003c/span\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\nimport { createComponent } from '@vue/composition-api'\nimport { usePromise } from 'vue-compose-promise'\n\nexport default createComponent({\n  setup() {\n    const promised = usePromise({ pendingDelay: 200, promise: fetchUsers() })\n\n    return {\n      usersPromise: promised.state,\n\n      fetchUsers() {\n        promised.state.promise = fetchUsers()\n      },\n    }\n  },\n})\n\u003c/script\u003e\n```\n\nBoth, `pendingDelay` and `promise` can be reactive values like a _computed_ property, a _ref_ or a _prop_:\n\n```js\nconst search = ref('')\nconst usersPromise = computed(() =\u003e featchUsers(search.value))\nconst promised = usePromise({\n  pendingDelay: props.displayLoaderDelay,\n  promise: usersPromise,\n})\n```\n\n## API\n\n### `usePromise\u003cT\u003e(options?: { pendingDelay?: number | Ref\u003cnumber\u003e; promise?: Promise\u003cT\u003e | Ref\u003cPromise\u003cT\u003e\u003e })`\n\n- `options`\n  - `pendingDelay`: amount of time in _ms_ that should be wait whenever the a new promise is pending. This allows delaying the display of a loader to avoid flashing the screen. Can be a _reactive_ property.\n  - `promise`: initial promise. Can be null. Can be a _reactive_ property.\n\n## Related\n\n- [vue-promised](https://github.com/posva/vue-promised)\n- [@vue/composition-api](https://github.com/vuejs/composition-api)\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposva%2Fvue-compose-promise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposva%2Fvue-compose-promise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposva%2Fvue-compose-promise/lists"}