Skip to content

Commit

Permalink
v2.5.11
Browse files Browse the repository at this point in the history
- `UIComponent`:
  - Optimize`_notifyRendered`.
  - Optimize `_scheduleCheckFinishedRendered`.
  • Loading branch information
gmpassos committed Dec 19, 2024
1 parent 0fa1058 commit 430da77
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.5.11

- `UIComponent`:
- Optimize`_notifyRendered`.
- Optimize `_scheduleCheckFinishedRendered`.

## 2.5.10

- sdk: '>=3.5.0 <4.0.0'
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bones_ui.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class BonesUI {
static const String version = '2.5.10';
static const String version = '2.5.11';
}
21 changes: 18 additions & 3 deletions lib/src/bones_ui_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>? _waitingRender;
Expand Down Expand Up @@ -1483,8 +1485,20 @@ abstract class UIComponent extends UIEventHandler {
_scheduleCheckFinishedRendered();
}

static Future<void>? _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() {
Expand All @@ -1496,7 +1510,8 @@ abstract class UIComponent extends UIEventHandler {
if (delay > 100) {
_notifyFinishRendered();
} else {
_scheduleCheckFinishedRendered();
Future.delayed(
Duration(milliseconds: 100), _scheduleCheckFinishedRendered);
}
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 430da77

Please sign in to comment.