1/* 2 * Copyright (c) 2023 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 * @file 18 * @kit ArkUI 19 */ 20 21/** 22 * Used to do observer layout and draw event for component. 23 * @syscap SystemCapability.ArkUI.ArkUI.Full 24 * @crossplatform 25 * @since 10 26 */ 27/** 28 * Used to do observer layout and draw event for component. 29 * 30 * @namespace inspector 31 * @syscap SystemCapability.ArkUI.ArkUI.Full 32 * @crossplatform 33 * @atomicservice 34 * @since 12 35 */ 36declare namespace inspector { 37 38 /** 39 * The ComponentObserver is used to listen for layout and draw events. 40 * @syscap SystemCapability.ArkUI.ArkUI.Full 41 * @crossplatform 42 * @since 10 43 */ 44 /** 45 * The ComponentObserver is used to listen for layout and draw events. 46 * 47 * @interface ComponentObserver 48 * @syscap SystemCapability.ArkUI.ArkUI.Full 49 * @crossplatform 50 * @atomicservice 51 * @since 12 52 */ 53 interface ComponentObserver { 54 55 /** 56 * Registers a callback with the corresponding query condition by using the handle. 57 * This callback is triggered when the component layout complete. 58 * @param { string } type - type of the listened event. 59 * @param { ()=>void } callback - callback of the listened event. 60 * @syscap SystemCapability.ArkUI.ArkUI.Full 61 * @crossplatform 62 * @since 10 63 */ 64 /** 65 * Registers a callback with the corresponding query condition by using the handle. 66 * This callback is triggered when the component layout complete. 67 * @param { 'layout' } type - type of the listened event. 68 * @param { function } callback - callback of the listened event. 69 * @syscap SystemCapability.ArkUI.ArkUI.Full 70 * @crossplatform 71 * @atomicservice 72 * @since 12 73 */ 74 on(type: 'layout', callback: () => void): void; 75 76 /** 77 * Deregisters a callback with the corresponding query condition by using the handle. 78 * This callback is not triggered when the component layout complete. 79 * @param { string } type - type of the listened event. 80 * @param { ()=>void } callback - callback of the listened event. 81 * @syscap SystemCapability.ArkUI.ArkUI.Full 82 * @crossplatform 83 * @since 10 84 */ 85 /** 86 * Deregisters a callback with the corresponding query condition by using the handle. 87 * This callback is not triggered when the component layout complete. 88 * @param { 'layout' } type - type of the listened event. 89 * @param { function } callback - callback of the listened event. 90 * @syscap SystemCapability.ArkUI.ArkUI.Full 91 * @crossplatform 92 * @atomicservice 93 * @since 12 94 */ 95 off(type: 'layout', callback?: () => void): void; 96 97 /** 98 * Registers a callback with the corresponding query condition by using the handle. 99 * This callback is triggered when the component draw complete. 100 * @param { string } type - type of the listened event. 101 * @param { ()=>void } callback - callback of the listened event. 102 * @syscap SystemCapability.ArkUI.ArkUI.Full 103 * @crossplatform 104 * @since 10 105 */ 106 /** 107 * Registers a callback with the corresponding query condition by using the handle. 108 * This callback is triggered when the component draw complete. 109 * @param { 'draw' } type - type of the listened event. 110 * @param { function } callback - callback of the listened event. 111 * @syscap SystemCapability.ArkUI.ArkUI.Full 112 * @crossplatform 113 * @atomicservice 114 * @since 12 115 */ 116 on(type: 'draw', callback: () => void): void; 117 118 /** 119 * Deregisters a callback with the corresponding query condition by using the handle. 120 * This callback is not triggered when the component draw complete. 121 * @param { string } type - type of the listened event. 122 * @param { ()=>void } callback - callback of the listened event. 123 * @syscap SystemCapability.ArkUI.ArkUI.Full 124 * @crossplatform 125 * @since 10 126 */ 127 /** 128 * Deregisters a callback with the corresponding query condition by using the handle. 129 * This callback is not triggered when the component draw complete. 130 * @param { 'draw' } type - type of the listened event. 131 * @param { function } callback - callback of the listened event. 132 * @syscap SystemCapability.ArkUI.ArkUI.Full 133 * @crossplatform 134 * @atomicservice 135 * @since 12 136 */ 137 off(type: 'draw', callback?: () => void): void; 138 } 139 140 /** 141 * Sets the component after layout or draw criteria and returns the corresponding listening handle 142 * @param { string } id - component id. 143 * @returns { ComponentObserver } create listener for observer component event. 144 * @syscap SystemCapability.ArkUI.ArkUI.Full 145 * @crossplatform 146 * @since 10 147 */ 148 /** 149 * Sets the component after layout or draw criteria and returns the corresponding listening handle 150 * @param { string } id - component id. 151 * @returns { ComponentObserver } create listener for observer component event. 152 * @syscap SystemCapability.ArkUI.ArkUI.Full 153 * @crossplatform 154 * @atomicservice 155 * @since 12 156 * @deprecated since 18 157 * @useinstead ohos.arkui.UIContext.UIInspector#createComponentObserver 158 */ 159 function createComponentObserver(id: string): ComponentObserver; 160} 161 162export default inspector; 163