Skip to content

Commit 455bf3e

Browse files
committed
Changed 29 solution
1 parent dbceec9 commit 455bf3e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

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

4-
interface InfiniteScrollParams<TRow> {
4+
type MakeInfiniteScrollParams<TRow> = {
55
key: keyof TRow;
6-
fetchRows: () => Promise<TRow[]>;
76
initialRows?: TRow[];
8-
}
7+
fetchRows: () => Promise<TRow[]> | TRow[];
8+
};
99

10-
const makeInfiniteScroll = <TRow>(params: InfiniteScrollParams<TRow>) => {
11-
const data: TRow[] = params.initialRows || [];
10+
const makeInfiniteScroll = <TRow>(params: MakeInfiniteScrollParams<TRow>) => {
11+
const data = params.initialRows || [];
1212

1313
const scroll = async () => {
1414
const rows = await params.fetchRows();
@@ -24,7 +24,7 @@ const makeInfiniteScroll = <TRow>(params: InfiniteScrollParams<TRow>) => {
2424
it("Should fetch more data when scrolling", async () => {
2525
const table = makeInfiniteScroll({
2626
key: "id",
27-
fetchRows: () => Promise.resolve([{ id: 1, name: "John" }]),
27+
fetchRows: async () => [{ id: 1, name: "John" }],
2828
});
2929

3030
await table.scroll();
@@ -72,6 +72,6 @@ it("Should allow you to pass initialRows", () => {
7272
]);
7373

7474
type tests = [
75-
Expect<Equal<typeof rows, Array<{ id: number; name: string }>>>,
75+
Expect<Equal<typeof rows, Array<{ id: number; name: string }>>>
7676
];
7777
});

0 commit comments

Comments
 (0)