64
64
import rx .operators .OperationTakeLast ;
65
65
import rx .operators .OperationTakeUntil ;
66
66
import rx .operators .OperationTakeWhile ;
67
+ import rx .operators .OperationTimestamp ;
67
68
import rx .operators .OperationToIterator ;
68
69
import rx .operators .OperationToObservableFuture ;
69
70
import rx .operators .OperationToObservableIterable ;
80
81
import rx .util .AtomicObservableSubscription ;
81
82
import rx .util .AtomicObserver ;
82
83
import rx .util .Range ;
84
+ import rx .util .Timestamped ;
83
85
import rx .util .functions .Action0 ;
84
86
import rx .util .functions .Action1 ;
85
87
import rx .util .functions .Func0 ;
@@ -251,13 +253,15 @@ public Subscription subscribe(final Map<String, Object> callbacks) {
251
253
*/
252
254
return protectivelyWrapAndSubscribe (new Observer () {
253
255
256
+ @ Override
254
257
public void onCompleted () {
255
258
Object onComplete = callbacks .get ("onCompleted" );
256
259
if (onComplete != null ) {
257
260
Functions .from (onComplete ).call ();
258
261
}
259
262
}
260
263
264
+ @ Override
261
265
public void onError (Exception e ) {
262
266
handleError (e );
263
267
Object onError = callbacks .get ("onError" );
@@ -266,6 +270,7 @@ public void onError(Exception e) {
266
270
}
267
271
}
268
272
273
+ @ Override
269
274
public void onNext (Object args ) {
270
275
onNext .call (args );
271
276
}
@@ -297,15 +302,18 @@ public Subscription subscribe(final Object o) {
297
302
*/
298
303
return protectivelyWrapAndSubscribe (new Observer () {
299
304
305
+ @ Override
300
306
public void onCompleted () {
301
307
// do nothing
302
308
}
303
309
310
+ @ Override
304
311
public void onError (Exception e ) {
305
312
handleError (e );
306
313
// no callback defined
307
314
}
308
315
316
+ @ Override
309
317
public void onNext (Object args ) {
310
318
onNext .call (args );
311
319
}
@@ -326,15 +334,18 @@ public Subscription subscribe(final Action1<T> onNext) {
326
334
*/
327
335
return protectivelyWrapAndSubscribe (new Observer <T >() {
328
336
337
+ @ Override
329
338
public void onCompleted () {
330
339
// do nothing
331
340
}
332
341
342
+ @ Override
333
343
public void onError (Exception e ) {
334
344
handleError (e );
335
345
// no callback defined
336
346
}
337
347
348
+ @ Override
338
349
public void onNext (T args ) {
339
350
if (onNext == null ) {
340
351
throw new RuntimeException ("onNext must be implemented" );
@@ -364,17 +375,20 @@ public Subscription subscribe(final Object onNext, final Object onError) {
364
375
*/
365
376
return protectivelyWrapAndSubscribe (new Observer () {
366
377
378
+ @ Override
367
379
public void onCompleted () {
368
380
// do nothing
369
381
}
370
382
383
+ @ Override
371
384
public void onError (Exception e ) {
372
385
handleError (e );
373
386
if (onError != null ) {
374
387
Functions .from (onError ).call (e );
375
388
}
376
389
}
377
390
391
+ @ Override
378
392
public void onNext (Object args ) {
379
393
onNextFunction .call (args );
380
394
}
@@ -395,17 +409,20 @@ public Subscription subscribe(final Action1<T> onNext, final Action1<Exception>
395
409
*/
396
410
return protectivelyWrapAndSubscribe (new Observer <T >() {
397
411
412
+ @ Override
398
413
public void onCompleted () {
399
414
// do nothing
400
415
}
401
416
417
+ @ Override
402
418
public void onError (Exception e ) {
403
419
handleError (e );
404
420
if (onError != null ) {
405
421
onError .call (e );
406
422
}
407
423
}
408
424
425
+ @ Override
409
426
public void onNext (T args ) {
410
427
if (onNext == null ) {
411
428
throw new RuntimeException ("onNext must be implemented" );
@@ -435,19 +452,22 @@ public Subscription subscribe(final Object onNext, final Object onError, final O
435
452
*/
436
453
return protectivelyWrapAndSubscribe (new Observer () {
437
454
455
+ @ Override
438
456
public void onCompleted () {
439
457
if (onComplete != null ) {
440
458
Functions .from (onComplete ).call ();
441
459
}
442
460
}
443
461
462
+ @ Override
444
463
public void onError (Exception e ) {
445
464
handleError (e );
446
465
if (onError != null ) {
447
466
Functions .from (onError ).call (e );
448
467
}
449
468
}
450
469
470
+ @ Override
451
471
public void onNext (Object args ) {
452
472
onNextFunction .call (args );
453
473
}
@@ -468,17 +488,20 @@ public Subscription subscribe(final Action1<T> onNext, final Action1<Exception>
468
488
*/
469
489
return protectivelyWrapAndSubscribe (new Observer <T >() {
470
490
491
+ @ Override
471
492
public void onCompleted () {
472
493
onComplete .call ();
473
494
}
474
495
496
+ @ Override
475
497
public void onError (Exception e ) {
476
498
handleError (e );
477
499
if (onError != null ) {
478
500
onError .call (e );
479
501
}
480
502
}
481
503
504
+ @ Override
482
505
public void onNext (T args ) {
483
506
if (onNext == null ) {
484
507
throw new RuntimeException ("onNext must be implemented" );
@@ -515,10 +538,12 @@ public void forEach(final Action1<T> onNext) {
515
538
* See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator"
516
539
*/
517
540
protectivelyWrapAndSubscribe (new Observer <T >() {
541
+ @ Override
518
542
public void onCompleted () {
519
543
latch .countDown ();
520
544
}
521
545
546
+ @ Override
522
547
public void onError (Exception e ) {
523
548
/*
524
549
* If we receive an onError event we set the reference on the outer thread
@@ -530,6 +555,7 @@ public void onError(Exception e) {
530
555
latch .countDown ();
531
556
}
532
557
558
+ @ Override
533
559
public void onNext (T args ) {
534
560
onNext .call (args );
535
561
}
@@ -581,6 +607,7 @@ public void forEach(final Object o) {
581
607
582
608
forEach (new Action1 () {
583
609
610
+ @ Override
584
611
public void call (Object args ) {
585
612
onNext .call (args );
586
613
}
@@ -2664,6 +2691,7 @@ public Observable<T> filter(final Object callback) {
2664
2691
final FuncN _f = Functions .from (callback );
2665
2692
return filter (this , new Func1 <T , Boolean >() {
2666
2693
2694
+ @ Override
2667
2695
public Boolean call (T t1 ) {
2668
2696
return (Boolean ) _f .call (t1 );
2669
2697
}
@@ -2792,6 +2820,7 @@ public <R> Observable<R> map(final Object callback) {
2792
2820
final FuncN _f = Functions .from (callback );
2793
2821
return map (this , new Func1 <T , R >() {
2794
2822
2823
+ @ Override
2795
2824
@ SuppressWarnings ("unchecked" )
2796
2825
public R call (T t1 ) {
2797
2826
return (R ) _f .call (t1 );
@@ -2836,6 +2865,7 @@ public <R> Observable<R> mapMany(final Object callback) {
2836
2865
final FuncN _f = Functions .from (callback );
2837
2866
return mapMany (this , new Func1 <T , Observable <R >>() {
2838
2867
2868
+ @ Override
2839
2869
@ SuppressWarnings ("unchecked" )
2840
2870
public Observable <R > call (T t1 ) {
2841
2871
return (Observable <R >) _f .call (t1 );
@@ -2944,6 +2974,7 @@ public Observable<T> onErrorResumeNext(final Object resumeFunction) {
2944
2974
final FuncN _f = Functions .from (resumeFunction );
2945
2975
return onErrorResumeNext (this , new Func1 <Exception , Observable <T >>() {
2946
2976
2977
+ @ Override
2947
2978
@ SuppressWarnings ("unchecked" )
2948
2979
public Observable <T > call (Exception e ) {
2949
2980
return (Observable <T >) _f .call (e );
@@ -3025,6 +3056,7 @@ public Observable<T> onErrorReturn(final Object resumeFunction) {
3025
3056
final FuncN _f = Functions .from (resumeFunction );
3026
3057
return onErrorReturn (this , new Func1 <Exception , T >() {
3027
3058
3059
+ @ Override
3028
3060
@ SuppressWarnings ("unchecked" )
3029
3061
public T call (Exception e ) {
3030
3062
return (T ) _f .call (e );
@@ -3360,6 +3392,14 @@ public <E> Observable<T> takeUntil(Observable<E> other) {
3360
3392
return takeUntil (this , other );
3361
3393
}
3362
3394
3395
+ /**
3396
+ * Adds a timestamp to each item emitted by this observable.
3397
+ * @return An observable sequence of timestamped items.
3398
+ */
3399
+ public Observable <Timestamped <T >> timestamp () {
3400
+ return create (OperationTimestamp .timestamp (this ));
3401
+ }
3402
+
3363
3403
/**
3364
3404
* Returns an Observable that emits a single item, a list composed of all the items emitted by
3365
3405
* the source Observable.
0 commit comments