Skip to content

The trigger supports `throttle`, `debounce` and `takeLeading` now

Compare
Choose a tag to compare
@ruanyl ruanyl released this 13 Jun 15:33
· 129 commits to master since this release

Breaking change

Removed actionTypeDelimiter from App constructor, this will enforce to use / as action type delimiter

New feature

The effects() trigger map now support throttle, debounce and takeLeading

  1. takeLeading example of only do fetching user once in one time
const [effects] = model.effects({}, {
  requestUser: {
    *takeLeading() {
      yield call(API.getUser)
    }
  }
})
  1. debounce example of decreasing the rate of validation function call when input changes
const [effects] = model.effects({}, {
  handleInputChange: {
    *debounce(input) {
      yield call(validate, input)
    },
    ms: 500,
  }
})
  1. throttle example of limiting the API calls of requesting suggestions on input changes
const [effects] = model.effects({}, {
  requestSuggestions: {
    *throttle(input) {
      yield call(API.findSuggestions, input)
    },
    ms: 1000,
  }
})