Skip to content

Commit dbceec9

Browse files
committed
Made 29 easier
1 parent a38c295 commit dbceec9

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/06-challenges/29-infinite-scroll.problem.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
import { expect, it } from "vitest";
22
import { Equal, Expect } from "../helpers/type-utils";
33

4-
const makeInfiniteScroll = (params: unknown) => {};
4+
const makeInfiniteScroll = (params: unknown) => {
5+
const data = params.initialRows || [];
6+
7+
const scroll = async () => {
8+
const rows = await params.fetchRows();
9+
data.push(...rows);
10+
};
11+
12+
return {
13+
scroll,
14+
getRows: () => data,
15+
};
16+
};
517

618
it("Should fetch more data when scrolling", async () => {
719
const table = makeInfiniteScroll({
@@ -54,6 +66,6 @@ it("Should allow you to pass initialRows", () => {
5466
]);
5567

5668
type tests = [
57-
Expect<Equal<typeof rows, Array<{ id: number; name: string }>>>,
69+
Expect<Equal<typeof rows, Array<{ id: number; name: string }>>>
5870
];
5971
});

0 commit comments

Comments
 (0)