Streamlined Future
FutureCompatible.swift
from the frameworkX
Future.Result
type with Swift.Result
Refined on
method to attach callbacks. There are just two minor changes:
() -> Void
instead of (Result) -> Void
. Completion is designed to be used in addition to success
and failure
to do things like hiding activity indicators. That's why the Result
variant never really made sense. If you'd like to use Result
instead, use future.materialize().on { result in }
.func on(success: (Value) -> Void)
method. Now future.on { }
(with a trailing closure) is inferred by the compiler to add success
closure. Previously, it used to attach completion
closure. This change makes it a little bit nices to attach callbacks to futures that can't produce errors (Future<_, Never>
).There is also a change in the project structure. We now use a single multi-platform target instead of four separate targets - one for each platform.
Future
initializer which takes a throwing closure: init(catching body: () throws -> Value)
. This feature was added in the first FutureX PR #1, thanks to @moto0000!castError
variant which takes an error type as an argumentScheduler.default
which can be used to change the default scheduler which is Scheduler.main
on
no longer returns Future
to enable some wiggle room in the futureCancellationToken.noOp
renamed to CancellationToken.none
.FutureCompatible
and FutureExtension
observe(on:)
is more flexible, it can now be used to runs transformations like map
, tryMap
on a specified queue (and actually any other transformations too, it composes really well with any of them).Future { succeed, fail in }
we now have Future { promise in }
which is consistent with the regular way you create Promise/Future pair and also more flexible and performant.Promise
. It's very often when there is only one callback for each Promise
. These operations are now up to 15% faster.CustomDebugStringConvertible
for Promise