Skip to content

v0.5.0

Compare
Choose a tag to compare
@lilyball lilyball released this 26 Feb 06:46
· 73 commits to master since this release
  • Rename a lot of methods on Promise and TokenPromise (#5).

    This gets rid of most overrides, leaving the only overridden methods to be ones that handle either Swift.Error or E: Swift.Error, and even these overrides are removed in the Swift 5 compiler.

    then is now map or flatMap, recover's override is now flatMapError, always's override is now flatMapResult, and similar renames were made for the try variants.

  • Add a new then method whose block returns Void. The returned promise resolves to the same result as the original promise.

  • Add new mapError and tryMapError methods.

  • Add new mapResult and tryMapResult methods.

  • Extend tryFlatMapError to be available on all Promises instead of just those whose error type is Swift.Error.

  • Remove the default .auto value for the on context: parameter to most calls. It's now only provided for the "terminal" callbacks, the ones that don't return a value from the handler. This avoids the common problem of running trivial maps on the main thread unnecessarily (#33).


Note: When upgrading to this version from previous versions, expect a lot of deprecation warnings. Not all of the warnings are accurate. In particular, code that looks like

somePromise().then({ [weak self] value in
    self?.doSomething(with: value)
})

will raise a warning suggesting this should be map(on:_:), due to the inferred ()? return type. This can be suppressed by writing value -> Void as the type signature instead. A future release will remove this deprecation warning.