Skip to content
This repository has been archived by the owner on Jul 3, 2022. It is now read-only.

Use of unresolved identifier 'FutureUtils' #44

Closed
paullexen opened this issue May 6, 2015 · 5 comments
Closed

Use of unresolved identifier 'FutureUtils' #44

paullexen opened this issue May 6, 2015 · 5 comments

Comments

@paullexen
Copy link

var allFutures = [future1, future2]
FutureUtils.sequence(allFutures).onSuccess { result in
    println("complete")
}

When attempting to use FutureUtils class like above, I get the following error:

Use of unresolved identifier 'FutureUtils'

Looks like the FutureUtils functions were turned into free functions here: 17d4f21. But when I change my code to a "free function":

var allFutures = [future1, future2]
sequence(allFutures).onSuccess { result in
    println("complete")
}

I get this error:

Cannot invoke 'onSuccess' with an argument list of type '((_) -> _)'

Any ideas of how to use the FutureUtils functions? Also, the documentation needs to be updated regarding the FutureUtils methods.

@Thomvis
Copy link
Owner

Thomvis commented May 6, 2015

You're completely right about the documentation regarding FutureUtils. Sorry about that.

In the tests, we do something similar to what you are trying to do: https://github.com/Thomvis/BrightFutures/blob/master/BrightFuturesTests/BrightFuturesTests.swift#L725. Can you try to figure out what the difference is and maybe see what is preventing your case from working?

@paullexen
Copy link
Author

Ah, I found the issue. My futures were returning different types. A simple way to recreate:

var future1 = Future.succeeded(1)
var future2 = Future.succeeded("string")        
var allFutures = [future1, future2]
sequence(allFutures).onSuccess { result in
    println("complete")
}

@Thomvis
Copy link
Owner

Thomvis commented May 6, 2015

Just curious: would it work if you explicitly type allFutures as [Future<Any>]?

@paullexen
Copy link
Author

Doesn't seem to. The following code generates a 'String' is not identical to 'Any' error on the third line:

var future1 = Future.succeeded(1)
var future2 = Future.succeeded("string")
var allFutures = [future1, future2] as [Future<Any>]
sequence(allFutures).onSuccess { result in
    println("complete")
}

However, adding the cast to the futures themselves does work:

var future1 = Future.succeeded(1) as Future<Any>
var future2 = Future.succeeded("string") as Future<Any>
var allFutures = [future1, future2] 
sequence(allFutures).onSuccess { result in
    println("complete")
}

@Thomvis
Copy link
Owner

Thomvis commented May 6, 2015

Thanks for the info. I just updated the README and pushed version 1.0.1. I'm closing this issue.

@Thomvis Thomvis closed this as completed May 6, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants