A saga to get a debounced value from a channel without cancelling the previous taken item's task. This is useful for when you need to incrementally save progress or updates (e.g. autosave), because without it you won't be able to receive responses from API calls that were triggered during the debounce process.
npm install --save redux-saga-debounced-channel
Also install peerDependencies (if not already installed)
npm install --save redux-saga
Usage:
import getDebouncedValueFromChannel from 'redux-saga-debounced-channel';
import { channel, Channel, SagaIterator } from 'redux-saga';
function* mySaga(): SagaIterator {
// any redux-saga channel can be used
const saveActionChannel: Channel<Action> = yield call(channel);
const debouncedSaveAction = yield getDebouncedValueFromChannel(
saveActionChannel,
500, // delay in ms
);
};
A saga that returns the last item on the channel after a specified delay.
getDebouncedValueFromChannel<T = AnyAction>(
actionChannel: Channel<T>,
delayInMs: number,
): SagaIterator
A redux-saga channel configured to receive the actions that need to be debounced
The amount of milliseconds to debounce by
Below is a list of commands you will probably find useful.
Runs the project in development/watch mode. Your project will be rebuilt upon changes. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.
Your library will be rebuilt if you make edits.
Bundles the package to the dist
folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
Runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.