diff --git a/CHANGELOG.md b/CHANGELOG.md index d0bc2aa..44a5f2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.5.11 + +- `UIComponent`: + - Optimize`_notifyRendered`. + - Optimize `_scheduleCheckFinishedRendered`. + ## 2.5.10 - sdk: '>=3.5.0 <4.0.0' diff --git a/lib/src/bones_ui.dart b/lib/src/bones_ui.dart index 106cf6d..acf63cf 100644 --- a/lib/src/bones_ui.dart +++ b/lib/src/bones_ui.dart @@ -1,3 +1,3 @@ class BonesUI { - static const String version = '2.5.10'; + static const String version = '2.5.11'; } diff --git a/lib/src/bones_ui_component.dart b/lib/src/bones_ui_component.dart index 3fe3cbc..801cf7c 100644 --- a/lib/src/bones_ui_component.dart +++ b/lib/src/bones_ui_component.dart @@ -1432,7 +1432,9 @@ abstract class UIComponent extends UIEventHandler { _waitingRender = null; } - Future.delayed(Duration(milliseconds: 1), () => onRender.add(this)); + if (onRender.isUsed) { + Future.delayed(Duration(milliseconds: 1), () => onRender.add(this)); + } } Completer? _waitingRender; @@ -1483,8 +1485,20 @@ abstract class UIComponent extends UIEventHandler { _scheduleCheckFinishedRendered(); } + static Future? _scheduleCheckFinishedRenderedFuture; + static void _scheduleCheckFinishedRendered() { - Future.delayed(Duration(milliseconds: 300), _checkFinishedRendered); + var future = _scheduleCheckFinishedRenderedFuture; + if (future != null) return; + + future = _scheduleCheckFinishedRenderedFuture = + Future.delayed(Duration(milliseconds: 300), _checkFinishedRendered); + + future.then((_) { + if (identical(future, _scheduleCheckFinishedRenderedFuture)) { + _scheduleCheckFinishedRenderedFuture = null; + } + }); } static void _checkFinishedRendered() { @@ -1496,7 +1510,8 @@ abstract class UIComponent extends UIEventHandler { if (delay > 100) { _notifyFinishRendered(); } else { - _scheduleCheckFinishedRendered(); + Future.delayed( + Duration(milliseconds: 100), _scheduleCheckFinishedRendered); } } diff --git a/pubspec.yaml b/pubspec.yaml index 0d5cd4d..9040bd6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: bones_ui description: Bones_UI - An intuitive and user-friendly Web User Interface framework for Dart. -version: 2.5.10 +version: 2.5.11 homepage: https://github.com/Colossus-Services/bones_ui environment: