Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support awaiting optional Promises #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

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%) ⬇️

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.

@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