Skip to content
On this page

useLazyPromise

Sugar for usePromise

This is only a sugar method to call Promise, passing the option for lazy, might not be clear enough.

Parameters

typescript
import { usePromiseLazy } from '@elonehoo/pistachio'

const use = usePromiseLazy(fn, throwException?)
import { usePromiseLazy } from '@elonehoo/pistachio'

const use = usePromiseLazy(fn, throwException?)
ParametersTypeRequiredDefaultDescription
fnFunctiontruePromise factory
throwExceptionbooleanfalsefalseExposes exception on exec()

State

Check usePromise#State

Methods

Check usePromise#Methods

Implementation

typescript
// this is basically the code for this with no typings

function usePromiseLazy(fn, throwException) {
  return usePromise(fn, {
    lazy: true,
    throwException
  })
}
// this is basically the code for this with no typings

function usePromiseLazy(fn, throwException) {
  return usePromise(fn, {
    lazy: true,
    throwException
  })
}

Released under the MIT License.