2.x: add sample() overload that can emit the very last buffered item #4955

merged 1 commit into from Jan 4, 2017


None yet

3 participants

akarnokd commented Jan 4, 2017 edited

The sample() operator in 1.x has been changed to always emit the very last buffered item before completion for 1.1.3: Discussion, PR.

This change has been forgotten in 2.x (because 2.x sample() was implemented several months earlier) but unlike 1.x, I don't want to break existing use cases, hence the introduction of 6 overloads (3 for each base type) that let's one define the "tail" behavior.

Note that the associated marble diagrams are inconsistent with the operators implemented, we need a new diagram where the timed-sample also emits the last value:


and one new diagram where the sampler-sample doesn't emit the last value:


The default sampler-sample should use this and the emitLast == true version can use the current diagram.

(I don't have a Mac thus can't run OmniGraffle).

Related: #4952

@akarnokd akarnokd added this to the 2.0 backlog milestone Jan 4, 2017

Current coverage is 95.57% (diff: 98.54%)

Merging #4955 into 2.x will decrease coverage by 0.15%

@@                2.x      #4955   diff @@
  Files           587        587          
  Lines         37551      37669   +118   
  Methods           0          0          
  Messages          0          0          
  Branches       5655       5675    +20   
+ Hits          35950      36003    +53   
- Misses          676        704    +28   
- Partials        925        962    +37   

Powered by Codecov. Last update 19fac95...9c7f28d

@akarnokd akarnokd merged commit 71330c0 into ReactiveX:2.x Jan 4, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
@akarnokd akarnokd deleted the akarnokd:SampleWithTail branch Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment