@@ -2123,6 +2123,31 @@ public Observable<T> delay(long delay, TimeUnit unit, Scheduler scheduler) {
2123
2123
return OperationDelay .delay (this , delay , unit , scheduler );
2124
2124
}
2125
2125
2126
+ /**
2127
+ * Return an Observable which delays the subscription to this Observable sequence
2128
+ * by the given amount.
2129
+ * @param delay the time to delay the subscription
2130
+ * @param unit the time unit
2131
+ * @return an Observable which delays the subscription to this Observable sequence
2132
+ * by the given amount.
2133
+ */
2134
+ public Observable <T > delaySubscription (long delay , TimeUnit unit ) {
2135
+ return delaySubscription (delay , unit , Schedulers .threadPoolForComputation ());
2136
+ }
2137
+
2138
+ /**
2139
+ * Return an Observable which delays the subscription to this Observable sequence
2140
+ * by the given amount, waiting and subscribing on the given scheduler.
2141
+ * @param delay the time to delay the subscription
2142
+ * @param unit the time unit
2143
+ * @param scheduler the scheduler where the waiting and subscription will happen
2144
+ * @return an Observable which delays the subscription to this Observable sequence
2145
+ * by the given amount, waiting and subscribing on the given scheduler
2146
+ */
2147
+ public Observable <T > delaySubscription (long delay , TimeUnit unit , Scheduler scheduler ) {
2148
+ return create (OperationDelay .delaySubscription (this , delay , unit , scheduler ));
2149
+ }
2150
+
2126
2151
/**
2127
2152
* Drops items emitted by an Observable that are followed by newer items
2128
2153
* before a timeout value expires. The timer resets on each emission.
@@ -5289,6 +5314,148 @@ public Observable<T> takeLast(final int count) {
5289
5314
return create (OperationTakeLast .takeLast (this , count ));
5290
5315
}
5291
5316
5317
+ /**
5318
+ * Return an Observable which contains the items from this observable which
5319
+ * were emitted not before this completed minus a time window.
5320
+ *
5321
+ * @param time the length of the time window, relative to the completion of this
5322
+ * observable.
5323
+ * @param unit the time unit
5324
+ * @return an Observable which contains the items from this observable which
5325
+ * were emitted not before this completed minus a time window.
5326
+ */
5327
+ public Observable <T > takeLast (long time , TimeUnit unit ) {
5328
+ return takeLast (time , unit , Schedulers .threadPoolForComputation ());
5329
+ }
5330
+
5331
+ /**
5332
+ * Return an Observable which contains the items from this observable which
5333
+ * were emitted not before this completed minus a time window, where the timing
5334
+ * information is provided by the given scheduler.
5335
+ *
5336
+ * @param time the length of the time window, relative to the completion of this
5337
+ * observable.
5338
+ * @param unit the time unit
5339
+ * @param scheduler the scheduler which provides the timestamps for the observed
5340
+ * elements
5341
+ * @return an Observable which contains the items from this observable which
5342
+ * were emitted not before this completed minus a time window, where the timing
5343
+ * information is provided by the given scheduler
5344
+ */
5345
+ public Observable <T > takeLast (long time , TimeUnit unit , Scheduler scheduler ) {
5346
+ return create (OperationTakeLast .takeLast (this , time , unit , scheduler ));
5347
+ }
5348
+
5349
+ /**
5350
+ * Return an Observable which contains at most count items from this Observable
5351
+ * which were emitted not before this completed minus a time window.
5352
+ *
5353
+ * @param count the maximum number of items to return
5354
+ * @param time the length of the time window, relative to the completion of this
5355
+ * observable.
5356
+ * @param unit the time unit
5357
+ * @return Return an Observable which contains at most count items from this Observable
5358
+ * which were emitted not before this completed minus a time window.
5359
+ */
5360
+ public Observable <T > takeLast (int count , long time , TimeUnit unit ) {
5361
+ return takeLast (count , time , unit , Schedulers .threadPoolForComputation ());
5362
+ }
5363
+
5364
+ /**
5365
+ * Return an Observable which contains at most count items from this Observable
5366
+ * which were emitted not before this completed minus a time window, where the timing
5367
+ * information is provided by the given scheduler.
5368
+ *
5369
+ * @param count the maximum number of items to return
5370
+ * @param time the length of the time window, relative to the completion of this
5371
+ * observable.
5372
+ * @param unit the time unit
5373
+ * @param scheduler the scheduler which provides the timestamps for the observed
5374
+ * elements
5375
+ * @return Return an Observable which contains at most count items from this Observable
5376
+ * which were emitted not before this completed minus a time window, where the timing
5377
+ * information is provided by the given scheduler
5378
+ */
5379
+ public Observable <T > takeLast (int count , long time , TimeUnit unit , Scheduler scheduler ) {
5380
+ if (count < 0 ) {
5381
+ throw new IllegalArgumentException ("count >= 0 required" );
5382
+ }
5383
+ return create (OperationTakeLast .takeLast (this , count , time , unit , scheduler ));
5384
+ }
5385
+
5386
+ /**
5387
+ * Return an Observable which emits single List containing the last count
5388
+ * elements from this Observable.
5389
+ *
5390
+ * @param count the number of items to take last
5391
+ * @return an Observable which emits single list containing the last count
5392
+ * elements from this Observable.
5393
+ */
5394
+ public Observable <List <T >> takeLastBuffer (int count ) {
5395
+ return takeLast (count ).toList ();
5396
+ }
5397
+
5398
+ /**
5399
+ * Return an Observable which emits single List containing items which
5400
+ * were emitted not before this completed minus a time window.
5401
+ * @param time the length of the time window, relative to the completion of this
5402
+ * observable.
5403
+ * @param unit the time unit
5404
+ * @return an Observable which emits single list containing items which
5405
+ * were emitted not before this completed minus a time window
5406
+ */
5407
+ public Observable <List <T >> takeLastBuffer (long time , TimeUnit unit ) {
5408
+ return takeLast (time , unit ).toList ();
5409
+ }
5410
+
5411
+ /**
5412
+ * Return an Observable which emits single List containing items which
5413
+ * were emitted not before this completed minus a time window, where the timing
5414
+ * information is provided by the given scheduler.
5415
+ * @param time the length of the time window, relative to the completion of this
5416
+ * observable.
5417
+ * @param unit the time unit
5418
+ * @param scheduler the scheduler which provides the timestamps for the observed
5419
+ * elements
5420
+ * @return an Observable which emits single list containing items which
5421
+ * were emitted not before this completed minus a time window, where the timing
5422
+ * information is provided by the given scheduler
5423
+ */
5424
+ public Observable <List <T >> takeLastBuffer (long time , TimeUnit unit , Scheduler scheduler ) {
5425
+ return takeLast (time , unit , scheduler ).toList ();
5426
+ }
5427
+
5428
+ /**
5429
+ * Return an Observable which emits a single List containing at most count items
5430
+ * from this Observable which were emitted not before this completed minus a time window.
5431
+ * @param count the number of items to take last
5432
+ * @param time the length of the time window, relative to the completion of this
5433
+ * observable.
5434
+ * @param unit the time unit
5435
+ * @return an Observable which emits a single List containing at most count items
5436
+ * from this Observable which were emitted not before this completed minus a time window.
5437
+ */
5438
+ public Observable <List <T >> takeLastBuffer (int count , long time , TimeUnit unit ) {
5439
+ return takeLast (count , time , unit ).toList ();
5440
+ }
5441
+
5442
+ /**
5443
+ * Return an Observable which emits a single List containing at most count items
5444
+ * from this Observable which were emitted not before this completed minus a time window.
5445
+ * @param count the number of items to take last
5446
+ * @param time the length of the time window, relative to the completion of this
5447
+ * observable.
5448
+ * @param unit the time unit
5449
+ * @param scheduler the scheduler which provides the timestamps for the observed
5450
+ * elements
5451
+ * @return an Observable which emits a single List containing at most count items
5452
+ * from this Observable which were emitted not before this completed minus a time window.
5453
+ */
5454
+ public Observable <List <T >> takeLastBuffer (int count , long time , TimeUnit unit , Scheduler scheduler ) {
5455
+ return takeLast (count , time , unit , scheduler ).toList ();
5456
+ }
5457
+
5458
+
5292
5459
/**
5293
5460
* Returns an Observable that emits the items from the source Observable
5294
5461
* only until the <code>other</code> Observable emits an item.
0 commit comments