-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Debouncing of SentryWidgetsBindingObserver.didChangeMetrics. #400…
… (#2232) * feat: add debouncer for SentryWidgetsBindingObserver.didChangeMetrics * adapt tests for debouncing * add changelog entry for debouncer * Update flutter/lib/src/utils/debouncer.dart Co-authored-by: Giancarlo Buenaflor <[email protected]> * Update flutter/test/widgets_binding_observer_test.dart Co-authored-by: Giancarlo Buenaflor <[email protected]> * add internal to debouncer and add whitespaces to comments --------- Co-authored-by: Giancarlo Buenaflor <[email protected]>
- Loading branch information
1 parent
73d70bf
commit 256df44
Showing
4 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'dart:async'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
@internal | ||
class Debouncer { | ||
final int milliseconds; | ||
Timer? _timer; | ||
|
||
Debouncer({required this.milliseconds}); | ||
|
||
void run(VoidCallback action) { | ||
_timer?.cancel(); | ||
_timer = Timer(Duration(milliseconds: milliseconds), action); | ||
} | ||
|
||
void dispose() { | ||
_timer?.cancel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters