rx
rx copied to clipboard
Why three different makeObserver(...) functions instead of one?
There exists:
auto makeObserver(E)(void delegate(E) doPut, void delegate() doCompleted, void delegate(Exception) doFailure)
auto makeObserver(E)(void delegate(E) doPut, void delegate() doCompleted)
auto makeObserver(E)(void delegate(E) doPut, void delegate(Exception) doFailure)
Since every delegate is checked anyway with:
if(_doDelegate !is null)
why not use only one function like this?
auto makeObserver(E)(void delegate(E) doPut, void delegate() doCompleted = null, void delegate(Exception) doFailure = null)
IMO this gives a simpler interface and it allows me to only provide a doPut delegate.
To take advantage of D's meta-programming strength, most operators perform optimization using "hasCompleted" and "hasFailure." The makeObserver function needs to toggle whether the return value has a "completed" method or a "failure" method, depending on the argument. It is difficult to do this with one function.