Advertisement
krle997

Untitled

Dec 5th, 2024
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const add = <Item, Store extends ItemsStore<Item>>(
  2.   update: (this: void, updater: Updater<Store>) => void
  3. ) => (items: Array<Item>, isStart = false): void => {
  4.   update((store) => {
  5.     if (isStart) {
  6.       store.items.unshift(...items);
  7.     } else {
  8.       store.items.push(...items);
  9.     }
  10.  
  11.     store.count += items.length;
  12.     store.skip += items.length;
  13.     store.hasMore = store.items.length < store.count;
  14.  
  15.     return store;
  16.   });
  17. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement