I am trying to generate an Observable through using and looking at last 4 data from another Observable. I am not able to figure it out yet.
I have a data class A(val b: B) . Then I have the following obeserver
// My value storer. That keeps on getting filled up
val rep = ReplayRelay.createWithSize<A>(4)
// Now I need to generate another Observable based on `rep` which looks at `b` for the last 4 sets of data anytime `rep` has new data
`fun generateObservable() : Observable<A>`
What I want do
- is observe
rep - Takes the last 4 items in
rep - Check if
val b: Band then send back one A, I do not want this to end, it should continuously keep on looking atrepfor every item it adds. - Return another observer around 3
Example -> Stream 1, 2, 3, 4, 5, 6
rep stream -> (looks at 1, 2, 3,4), (looks at 2,3,4,5), (looks at 3,4,5,6)
Thanks all!
I looked into scan which only looks at the last 2, looked into take and takeLast that ends the Observable. buffer doesnt work as I need to look at the last 4 and not skip. I looked at buffer but I cant provide negative values.