Closed
Description
The operator elementAt
could be improved in several ways:
- It could request
index
amount upfront so it doesn't have to request(1) at every skipped value- this could be achieved with unconditional requesting in
onStart()
+SingleDelayedProducer
or conditionally when the child subscriber actually requests a positive value(i.e.,if (n > 0 && once.compareAndSet(false, true)) request(index)
)
- this could be achieved with unconditional requesting in
- Once the required element arrives, one should call
this.unsubscribe()
inonNext()
.- Note that the parent subscriber can't directly wrap the child subscriber anymore.
- I'd also do a
currentIndex < index
check inonError
in case an error happens after the indexth element and it slips through.