Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use clock package #661

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/src/streams/timer.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:async';

import 'package:clock/clock.dart';

/// Emits the given value after a specified amount of time.
///
/// ### Example
@@ -25,7 +27,7 @@ class TimerStream<T> extends Stream<T> {
}

static StreamController<T> _buildController<T>(T value, Duration duration) {
final watch = Stopwatch();
final watch = clock.stopwatch();
Timer? timer;
late StreamController<T> controller;
Duration? totalElapsed = Duration.zero;
3 changes: 2 additions & 1 deletion lib/src/transformers/time_interval.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:async';

import 'package:clock/clock.dart';
import 'package:rxdart/src/utils/forwarding_sink.dart';
import 'package:rxdart/src/utils/forwarding_stream.dart';

class _TimeIntervalStreamSink<S> extends ForwardingSink<S, TimeInterval<S>> {
final _stopwatch = Stopwatch();
final _stopwatch = clock.stopwatch();

@override
void onData(S data) {
4 changes: 3 additions & 1 deletion lib/src/transformers/timestamp.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import 'dart:async';

import 'package:clock/clock.dart';

class _TimestampStreamSink<S> implements EventSink<S> {
final EventSink<Timestamped<S>> _outputSink;

_TimestampStreamSink(this._outputSink);

@override
void add(S data) {
_outputSink.add(Timestamped(DateTime.now(), data));
_outputSink.add(Timestamped(clock.now(), data));
}

@override
3 changes: 3 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -8,6 +8,9 @@ repository: https://github.com/ReactiveX/rxdart
environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
clock: ^1.1.0

dev_dependencies:
build_runner: ^2.1.2
build_web_compilers: ^3.0.0