Last updated:
0 purchases
just throttle it
just_throttle_it #
A simple throttle library for Dart. Supports throttling by function and stream throttling.
import 'package:just_throttle_it/just_throttle_it.dart';
Throttle.milliseconds(1000, print, ["Throttle World!"]);
copied to clipboard
Static methods #
There are three methods available for throttling. A value of true will be returned if the function call is successful, and false if the function has been blocked. All methods differ only by the first parameter used to specify timeout values in different formats:
Throttle.seconds(int timeoutSeconds,
Function target,
[List<dynamic> positionalArguments,
Map<Symbol, dynamic> namedArguments])
copied to clipboard
Throttle.milliseconds(int timeoutMs,
Function target,
[List<dynamic> positionalArguments,
Map<Symbol, dynamic> namedArguments])
copied to clipboard
Throttle.duration(Duration timeout,
Function target,
[List<dynamic> positionalArguments,
Map<Symbol, dynamic> namedArguments])
copied to clipboard
To clear a throttled target, allowing the next throttled call to be immediately executed:
Throttle.clear(Function target)
copied to clipboard
Stream Throttling #
Use ThrottleStreamTransfomer to throttle any stream by a specified duration.
ThrottleStreamTransfomer(Duration timeout)
copied to clipboard
ThrottleStreamTransfomer.seconds(int timeoutSeconds)
copied to clipboard
ThrottleStreamTransfomer.milliseconds(int timeoutMs)
copied to clipboard
Stream throttleStream(Stream input) => input.transform(ThrottleStreamTransformer.seconds(1));
copied to clipboard
Example #
A quick demonstration can be found in the example directory. To run the example:
pub run example/main.dart
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.