1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16
17class MyDataSource {
18  data: string[] = ["a", "b", "c", "d", "e"];
19  public totalCount(): number {
20      return this.data.length;
21  }
22  public getData(index: number): string {
23      return this.data[index];
24  }
25}
26
27// A simplified version of ArkUI `LazyForEach` in SDK
28class LazyForEach {
29    create(id: string, component: any, source: any, itemGenFunction: any, itemIdFunc: any): void {};
30}
31
32let lazyforeach: LazyForEach = new LazyForEach();
33
34class MyComponent {
35  constructor(params, __localStorage) {
36      this.source = new MyDataSource();
37      this.setInitiallyProvidedValue(params);
38  }
39  setInitiallyProvidedValue(params) {
40      if (params.source !== undefined) {
41          this.source = params.source;
42      }
43  }
44  observeComponentCreation2() {};
45  private source: MyDataSource;
46  initialRender() {
47      this.observeComponentCreation2();
48      {
49          const __lazyForEachItemGenFunction = (_item, index?: number) => {
50              const item = _item;
51              {
52                  const observedDeepRender = () => {
53                  };
54                  observedDeepRender();
55              }
56          };
57          const __lazyForEachItemIdFunc = (item: string, index?: number) => index?.toString() + item;
58          lazyforeach.create("1", this, this.source, __lazyForEachItemGenFunction, __lazyForEachItemIdFunc);
59      }
60  }
61}