Skip to content

Instantly share code, notes, and snippets.

@Rajatgms
Created August 3, 2020 17:43
Show Gist options
  • Save Rajatgms/be285ab0e34b1c99554a9b7422dc39b5 to your computer and use it in GitHub Desktop.
Save Rajatgms/be285ab0e34b1c99554a9b7422dc39b5 to your computer and use it in GitHub Desktop.
Async Action Condition
import { createAsyncThunk } from '@reduxjs/toolkit';
import fetchMarketItems from '../API/fetchMarketItems';
export const fetchAllItems = createAsyncThunk(
'items/fetchAllItems',
fetchMarketItems,
{
condition: (arg, api) => {
return !api.getState().items.length > 0;
},
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment