1.2.4 • Published 2 years ago

@altipla/promises v1.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

promises

Promises utilities.

Install

npm i @altipla/promises

Usage

Resolve multiple promises in parallel

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:

<template>
  <button @click="run"></button>
</template>

<script lang="ts">
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,
    }
  }
})
</script>

Then outside the component you can wait for your promise:

<template>
  <my-component @action="$event.waitUntil(foo())"></my-component>
</template>

<script lang="ts">
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,
    }
  }
}
</script>
1.2.4

2 years ago

1.2.0

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.7

4 years ago

0.1.1

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.0

4 years ago