AwaitKit icon indicating copy to clipboard operation
AwaitKit copied to clipboard

Support awaiting optional Promises

Open WilsonGramer opened this issue 5 years ago • 2 comments

This PR adds support for awaiting optional promises, which allows for optional chaining inside an await function, like so:

try await(self.foo?.bar())

If the promise is nil, await immediately returns nil and does nothing more; otherwise it executes the promise as normal and returns an Optional wrapping the awaited value. This is implemented for both Promises and Guarantees.

This should resolve #19 — please let me know what you think, and thank you for providing this library!

WilsonGramer avatar Oct 26 '19 02:10 WilsonGramer

Codecov Report

Merging #49 into master will decrease coverage by 2.35%. The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #49      +/-   ##
==========================================
- Coverage     100%   97.64%   -2.36%     
==========================================
  Files           4        4              
  Lines          75       85      +10     
==========================================
+ Hits           75       83       +8     
- Misses          0        2       +2
Impacted Files Coverage Δ
Sources/AwaitKit/AwaitKit.swift 90% <80%> (-10%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 743fbf2...d7dbe94. Read the comment docs.

codecov[bot] avatar Oct 26 '19 03:10 codecov[bot]

Hey @yannickl, what's the status on this PR? Thanks 😄

WilsonGramer avatar Nov 03 '19 01:11 WilsonGramer