@livechat/saga-utils

    0.1.0 • Public • Published

    @livechat/saga-utils


    Utils

    backoffRetry(min, max, saga, ...args)

    Example usage

    import { backoffRetry } from '@livechat/saga-utils'
     
    function* mightThrowSaga() {
      if (Math.random() > 0.5) {
        return 42
      }
     
      throw new Error('Answer has not been found.')
    }
     
    function* someSaga() {
      const answer = yield call(backoffRetry, 100, 20000, mightThrowSaga)
    }

    safe(saga, ...args)

    import { safe } from '@livechat/saga-utils'
     
    function* mightThrowSaga(random) {
      if (random > 0.5) {
        return 42
      }
     
      throw new Error('Answer has not been found.')
    }
     
    function* someSaga() {
      yield fork(safe, mightThrowSaga, Math.random())
      // ... you can safely proceed
    }

    waitForState(selector, ...args)

    import { waitForState } from '@livechat/saga-utils'
     
    const getActiveChatId = state => state.activeChat
     
    function* someSaga() {
      const activeChatId = yield call(waitForState, getActiveChatId)
    }

    Install

    npm i @livechat/saga-utils

    DownloadsWeekly Downloads

    557

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • jawinski
    • andarist
    • konradk
    • walaszczykm
    • klarzynskik
    • bartoszgamza