| 225 | * @param callback - A function to execute on every child. If function returns false it breaks the iteration. |
| 226 | */ |
| 227 | export function eachDescendant(view: ViewBase, callback: (child: ViewBase) => boolean) { |
| 228 | if (!callback || !view) { |
| 229 | return; |
| 230 | } |
| 231 | |
| 232 | let continueIteration: boolean; |
| 233 | const localCallback = function (child: ViewBase): boolean { |
| 234 | continueIteration = callback(child); |
| 235 | if (continueIteration) { |
| 236 | child.eachChild(localCallback); |
| 237 | } |
| 238 | |
| 239 | return continueIteration; |
| 240 | }; |
| 241 | |
| 242 | view.eachChild(localCallback); |
| 243 | } |
| 244 | |
| 245 | let viewIdCounter = 1; |
| 246 | |