Redux Toolkit Action Creators should expensive logic be in setTimeout()?
Use case there is filtering box which filters data. In the code below there is action creator responsible for first updating the state of the filter box and then updating the filtered data.
When I dont wrap filtering logic in setTimeout there is a noticable lag in the UI of the filtering box (changing the filtering words becomes hindered). So is it advised practice to put heavier logic within the action creators in something like setTimeout()?
export const filteringWordsChanged = (newWords: string) => (dispatch: any, getState: any) => {
// Send Action to make sure the filter box insides are updated.
dispatch(updateFilteringWords(newWords));
let callback = () => {
let filtered = performFilteringLogic(getState(), newWords);
dispatch(updateFilteredResults(filtered));
};
// callback();
setTimeout(callback, 0);
}