Skip to content

Commit

Permalink
run every function in the queue
Browse files Browse the repository at this point in the history
  • Loading branch information
ibnlanre committed Nov 20, 2023
1 parent a469bb4 commit e5e5574
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/component/atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,9 @@ export function atom<
* @returns {() => void} A function to cleanup the atom `use` event upon unmount.
*/
const executeQueue = (useArgs: UseArgs) => {
const handleUse = Array.from(queue).pop();
if (handleUse) {
dispose("rerun");
handleUse(...useArgs);
queue.clear();
}
dispose("rerun");
queue.forEach((fn) => fn(...useArgs));
queue.clear();
};

const setValueWithArgs = (value: SetStateAction<State>) => {
Expand Down

0 comments on commit e5e5574

Please sign in to comment.