Recoil prevent UI blocking
Andon Mitev
Posted on September 27, 2022
I'm using recoil and I have a heavy/time consuming operation which blocks the UI until it is done. In redux, we use saga for side effects to prevent UI blocking. How this can be achieved here?
Currently, I have this state:
export const clientsState = atom({
key: 'clients',
default: {},
effects: [
({ setSelf, onSet }) => {
onSet((seed) => {
for (let i = 0; i < 100; i++) {
console.log(i);
// Time consuming operation
const clients = createClients(seed as string);
setSelf(clients);
}
});
},
],
});
and it takes a good amount of time to complete and unblock the UI.
💖 💪 🙅 🚩
Andon Mitev
Posted on September 27, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
webdev Understanding HTTP, Cookies, Email Protocols, and DNS: A Guide to Key Internet Technologies
November 30, 2024