Skip to content

Conversation

@WilsonGramer
Copy link

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!

This is to allow optional chaining inside an 'await' function, eg:

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

If the promise is 'nil', 'await' immediately returns 'nil' and does
nothing more.
@codecov
Copy link

codecov bot commented Oct 26, 2019

Codecov Report

Attention: Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 97.64%. Comparing base (743fbf2) to head (d7dbe94).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
Sources/AwaitKit/AwaitKit.swift 80.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##            master      #49      +/-   ##
===========================================
- Coverage   100.00%   97.64%   -2.36%     
===========================================
  Files            4        4              
  Lines           75       85      +10     
===========================================
+ Hits            75       83       +8     
- Misses           0        2       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@WilsonGramer
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optional value - Elvis Operator

1 participant