Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/altipla-consulting/promises
Promises utilities.
https://github.com/altipla-consulting/promises
Last synced: about 1 month ago
JSON representation
Promises utilities.
- Host: GitHub
- URL: https://github.com/altipla-consulting/promises
- Owner: altipla-consulting
- License: mit
- Created: 2021-08-14T23:41:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-21T09:15:30.000Z (over 1 year ago)
- Last Synced: 2024-11-14T14:46:52.975Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@altipla/promises
- Size: 127 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# promises
Promises utilities.
## Install
```sh
npm i @altipla/promises
```## Usage
### Resolve multiple promises in parallel
```js
import { resolveAll } from '@altipla/promises'let { foo, bar } = await resolveAll({
foo: client.List(),
bar: otherPromise,
})
```### Run a Vue event handler with a promise return
Run the action from the component method:
```vue
import { defineComponent } from 'vue'
export default defineComponent({
name: 'my-component',setup(props, { emit }) {
async function run() {
await runAction(this.$emit)// If you want to customize the action name or the argument.
await runAction(this.$emit, 'action', value)// Things you want to run after the promise of the other component is resolved
...
}return {
run,
}
}
})```
Then outside the component you can wait for your promise:
```vue
import { defineComponent } from 'vue'
export default defineComponent({
setup(props, { emit }) {
async function foo() {
// Do anything you need, my-component will wait for this before continuing
// with the code after the runAction call.
}return {
foo,
}
}
}```