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

Can't use fulfill with Promise<Void> #79

Closed
bes opened this issue Nov 6, 2018 · 2 comments
Closed

Can't use fulfill with Promise<Void> #79

bes opened this issue Nov 6, 2018 · 2 comments

Comments

@bes
Copy link

bes commented Nov 6, 2018

Hi,

I can't figure out how to use fulfill with a Promise<Void>.

func doSomethingInBackground() -> Promise<Void> {
    return Promise<Void>(on: bgQueue) {
        fulfill, reject in
        myMoc.perform {
            fulfill() // compiler complains Missing argument for parameter #1 in call
        }
    }
}

fulfill(nil) doesn't work either.

What is your recommendation on how to initialize an async Promise which does not have a logical return value?

@ghost
Copy link

ghost commented Nov 6, 2018

@bes try

func doSomethingInBackground() -> Promise<Void> {
    return Promise<Void>(on: bgQueue) {
        fulfill, reject in
        myMoc.perform {
             fulfill(())
        }
    }
}

from Swift -> Misc:
public typealias Void = ()

but I don't know why fulfill(Void) don't work

@bes
Copy link
Author

bes commented Nov 6, 2018

@umbri Thanks, it worked! I tried fulfill(Void) before, but as you said it does not seem to work. But fulfill(()) works.

@bes bes closed this as completed Nov 6, 2018
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

No branches or pull requests

1 participant