CallbackLimiter class

Runs the callback as soon as possible and limits the calling frequency to one call per duration.

Use case: Preventing a user from making numerous expensive requests (e.g. by pressing a button repeatedly withing a short timespan).

Inheritance

Constructors

CallbackLimiter({required Duration duration})

Properties

current ↔ TimeStampedCallbackControllerState
The current state.
getter/setter pairinherited
duration → Duration
After the event delaying is added the stream will wait for at least duration before the event CallbackControllerState.ready is added.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
hasTimedOut → bool
Returns true if the last state added to stream was delaying and DateTime.now is after current.dateTimeStamp plus duration.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stream → Stream<CallbackControllerState>
A stream with events of type CallbackControllerState.
no setterinherited

Methods

close() → Future
Closes the controller such that no further events will be added to stream. Any unfinished timers will be cancelled.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(void callback()) → void
Runs callback and adds events to stream.
override
runAsync(Future<void> callback()) → Future<void>
Runs callback and adds events to stream using the following sequence:
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited