LCOV - code coverage report
Current view: top level - src/rx - rx_event.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 17 17 100.0 %
Date: 2020-06-02 18:55:34 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:get/get.dart';
       2             : import 'rx_interface.dart';
       3             : import 'utils/debouncer.dart';
       4             : 
       5           1 : void ever(RxInterface listener, Function(dynamic) callback) {
       6           4 :   listener.subject.stream.listen((event) {
       7           2 :     callback(event.$new);
       8             :   });
       9             : }
      10             : 
      11           1 : void once(RxInterface listener, Function(dynamic) callback) {
      12             :   int times = 0;
      13           4 :   listener.subject.stream.listen((event) {
      14           1 :     times++;
      15           1 :     if (times < 2) {
      16           2 :       callback(event.$new);
      17             :     }
      18             :   });
      19             : }
      20             : 
      21           1 : void interval(RxInterface listener, Function(dynamic) callback,
      22             :     {Duration time}) {
      23             :   bool debounceActive = false;
      24           4 :   listener.subject.stream.listen((event) async {
      25             :     if (debounceActive) return null;
      26             :     debounceActive = true;
      27           2 :     await Future.delayed(time ?? Duration(seconds: 1));
      28             :     debounceActive = false;
      29           2 :     callback(event.$new);
      30             :   });
      31             : }
      32             : 
      33           1 : void debounce(RxInterface listener, Function(dynamic) callback,
      34             :     {Duration time}) {
      35           1 :   final _debouncer = Debouncer(delay: time ?? Duration(milliseconds: 800));
      36           4 :   listener.subject.stream.listen((event) {
      37           2 :     _debouncer(() {
      38           2 :       callback(event.$new);
      39             :     });
      40             :   });
      41             : }

Generated by: LCOV version 1.14