1.0.10 • Published 3 years ago

redux-polling-thunk v1.0.10

Weekly downloads
53
License
MIT
Repository
github
Last release
3 years ago

redux-polling-thunk

A helper to create polling logic inside your store based on redux-thunk middleware.

(5kb gzipped)

Install

npm install redux-polling-thunk

Usage

import { createPolling } from 'redux-pollling-thunk'

dispatch(
  createPolling('infinite-appplication-version-check', {
    getPollingRegistration: (state, name) => state.ui.polling[name],
    registerPolling: name => // dispatch an action to register the polling
    unregisterPolling: name  => // dispatch an action to unregister the polling,
    fetchFunction: () => loadApplicationVersion(),
    shouldStartCondition: () => true,
    shouldContinueCondition: () => true,
    timeout: 600000
  })
)

Parameters

ParameterRequiredDescription
namexPolling name. It is allowed to only have 1 unique polling at a time.
options.fetchFunctionxFunction that fetches resources.
options.getPollingRegistrationxFunction that reads the status of the polling from the store.
options.registerPollingxFunction to persist the status of the polling to the store.
options.unregisterPollingxFunction to remove the status of the polling from the store.
options.shouldStartConditionxFunction to check if the polling is always of actuality. Checked before the actual fetch request.
options.shouldContinueConditionxFunction to check whether to continue the polling regarding the previous polling result.
options.onErrorFunction executed on error.
options.onFinishFunction executed right after that shouldContinueCondition becomes false.
options.timeoutPolling timeout.
1.0.10

3 years ago

1.0.9

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago