async
async copied to clipboard
Added Condition and boundedForEach
Adding:
-
Notifierwithwaitthat'll be resolved whennotify()is called. This is a primitive for signaling. -
Stream.parallelForEach(maxParallel, eachFn, onError)for callingeachFnin parallel for each item in the stream.
It's possible that onError really should be called ignoreError and only take Object e or even Exception e. Since:
- You shouldn't use the stack trace to decide if you are ignoring an error.
- You should never ignore an error, only exceptions.
Or maybe we should call it continueIf, because it really makes sense to write:
continueIf: (Exception e) => e is TimeoutException and things like that.
Having an onError method where you can choose to rethrow or not is really bad. Because Error.throwWithStackTrace is annoying to call, so people are likely to loose their stack traces.