Skip to content

Commit

Permalink
Change request lock duration
Browse files Browse the repository at this point in the history
  • Loading branch information
robertodoering committed Mar 7, 2021
1 parent c7d14ef commit c6062bb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/core/api/request_lock_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/// A lock for requests to prevent successive calls for a given duration.
///
/// Used to prevent spamming a request when the request is triggered
/// automatically (e.g. when scroll at the end of a list to load more
/// paginated data).
mixin RequestLock {
bool _isLocked = false;
bool get isLocked => _isLocked;
Expand All @@ -8,7 +12,7 @@ mixin RequestLock {
/// Returns `false` if [_isLocked] was `false` before.
/// Returns `true` if it was already locked.
bool lock({
Duration duration = const Duration(seconds: 5),
Duration duration = const Duration(seconds: 2),
}) {
if (!_isLocked) {
_isLocked = true;
Expand Down

0 comments on commit c6062bb

Please sign in to comment.