Why is the work only replaying the last value?
In Action.swift, only the last value emitted by work factory is being replayed. Is it intentional?
return Observable.of(workFactory(input)
.do(onError: { errorsSubject.onNext(.underlyingError($0)) })
.share(replay: 1, scope: .forever))
This have the side effect that trying to share the last execution, only the last value is being replayed.
Yes; if we replayed all values, the memory use would grow forever as more executions are called. Rather than replay an arbitrary number of elements, we use 1 (which is necessary to compute internal state, if I recall correctly). Let me know what I can clarify.
Understood. I wonder if it would be better to not replay anything at all in this case and calculate the state differently. Because one may incorrectly assume that only one value got sent.
Yeah, I can see why you'd get that impression from reading the code. From the outside perspective, I think our API contract adheres to RxSwift norms. You wouldn't normally expect to get all values from a stream when you subscribe to it, but having the current value (that is to say, subscribing to the observable and doing stuff with it right away) is often useful. Let me know what I can clarify here 👍
@ashfurrow @c0diq Should we remove implicit replay latest value and leave developer to decide if they need to?
I think we need the last value, if an existing Action gets assigned to .rx.action on seem UI element, that element needs to set its enabled state right away.
@ashfurrow I see now we only need isEnabled to set enable states UI element .rx.action.