1/* 2 * Copyright (c) 2021 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/** 17 * Data Change Listener. 18 * @since 7 19 */ 20declare interface DataChangeListener { 21 /** 22 * Data ready. 23 * @since 7 24 */ 25 onDataReloaded(): void; 26 27 /** 28 * Data added. 29 * @since 7 30 * @deprecated since 8 31 */ 32 onDataAdded(index: number): void; 33 34 /** 35 * Data added. 36 * @since 8 37 */ 38 onDataAdd(index: number): void; 39 40 /** 41 * Data moved. 42 * @since 7 43 * @deprecated since 8 44 */ 45 onDataMoved(from: number, to: number): void; 46 47 /** 48 * Data moved. 49 * @since 8 50 */ 51 onDataMove(from: number, to: number): void; 52 53 /** 54 * Data deleted. 55 * @since 7 56 * @deprecated since 8 57 */ 58 onDataDeleted(index: number): void; 59 60 /** 61 * Data deleted. 62 * @since 8 63 */ 64 onDataDelete(index: number): void; 65 66 /** 67 * Call when has data change. 68 * @since 7 69 * @deprecated since 8 70 */ 71 onDataChanged(index: number): void; 72 73 /** 74 * Call when has data change. 75 * @since 8 76 */ 77 onDataChange(index: number): void; 78} 79 80/** 81 * Developers need to implement this interface to provide data to LazyForEach component. 82 * @since 7 83 */ 84declare interface IDataSource { 85 /** 86 * Total data count. 87 * @since 7 88 */ 89 totalCount(): number; 90 91 /** 92 * Return the data of index. 93 * @since 7 94 */ 95 getData(index: number): any; 96 97 /** 98 * Register data change listener. 99 * @since 7 100 */ 101 registerDataChangeListener(listener: DataChangeListener): void; 102 103 /** 104 * Unregister data change listener. 105 * @since 7 106 */ 107 unregisterDataChangeListener(listener: DataChangeListener): void; 108} 109 110/** 111 * Lazy loading. 112 * @since 7 113 */ 114interface LazyForEachInterface { 115 /** 116 * Enter the value to obtain the LazyForEach. 117 * @since 7 118 */ 119 ( 120 dataSource: IDataSource, 121 itemGenerator: (item: any, index?: number) => void, 122 keyGenerator?: (item: any, index?: number) => string, 123 ): LazyForEachInterface; 124} 125 126declare const LazyForEach: LazyForEachInterface; 127