For an Rx based change tracking solution I am in need of an operator which can get me the first and most recent item in an observable sequence.
How would I write an Rx operator that produces the following marble diagram (Note: the brackets are used just to lineup the items…I’m not sure how best to represent this in text):
xs:---[a ]---[b ]-----[c ]-----[d ]---------|
desired:---[a,a]---[a,b]-----[a,c]-----[a,d]---------|
Using the same naming as @Wilka you can use the below extension which is somewhat self-explanatory:
Note that it doesn’t necessarily return a
Tuple, but rather gives you the option of passing a selector function on the result. This keeps it in line with the underlying primary operation (CombineLatest). This is obviously easily changed.Usage (if you want Tuples in the resulting stream):