PromiseKit: can't call custom code between then handlersHow to call Objective-C code from SwiftGlobal function sequence(state:next:) and type inferenceExtension of Array of FloatingPoint Elements in Swift 3.0Generic functions and Subclasses. Can anyone explain this compile error?Why can't the Swift compiler infer this closure's type?Disambiguate a complex closure return type (foo -> _)Swift: Ambiguous reference to member 'map'PromiseKit firstly around code, not function callCaching in Swift 4.2 using PromiseKit 6How do I test retry attempts in PromiseKit?
Handling Null values (and equivalents) routinely in Python
Does "Captain Marvel" contain spoilers for "Avengers: Infinity War"?
Is the book wrong about the Nyquist Sampling Criterion?
Mug and wireframe entirely disappeared
Where are the "shires" in the UK?
Why is my arithmetic with a long long int behaving this way?
Where to draw the line between quantum mechanics theory and its interpretation(s)?
Would a small hole in a Faraday cage drastically reduce its effectiveness at blocking interference?
Can my 2 children, aged 10 and 12, who are US citizens, travel to the USA on expired American passports?
Should I simplify my writing in a foreign country?
Power OctoPi from printer
My first c++ game (snake console game)
Kanji etymology of 毎?
Why would a military not separate its forces into different branches?
Which US defense organization would respond to an invasion like this?
Can there be a single technologically advanced nation, in a continent full of non-technologically advanced nations?
How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?
What to use instead of cling film to wrap pastry
Why didn't this character get a funeral at the end of Avengers: Endgame?
Correct way of drawing empty, half-filled and fully filled circles?
How do I calculate how many of an item I'll have in this inventory system?
Checking if two expressions are related
Has the United States ever had a non-Christian President?
Find magical solution to magical equation
PromiseKit: can't call custom code between then handlers
How to call Objective-C code from SwiftGlobal function sequence(state:next:) and type inferenceExtension of Array of FloatingPoint Elements in Swift 3.0Generic functions and Subclasses. Can anyone explain this compile error?Why can't the Swift compiler infer this closure's type?Disambiguate a complex closure return type (foo -> _)Swift: Ambiguous reference to member 'map'PromiseKit firstly around code, not function callCaching in Swift 4.2 using PromiseKit 6How do I test retry attempts in PromiseKit?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Just started with PromiseKit and running into a weird
compile problem:
- with firstly: Ambiguous reference to member 'firstly(execute:)' ()
- without firstly: Unable to infer complex closure return type; add explicit
Not sure what I am doing wrong here.
Promise
func test(someValue: Int) -> Promise<Void>
return Promise seal in
// do something with someValue
seal.fulfill(())
This works:
firstly
test(someValue: 2)
.then
test(someValue: 1)
.catch error in
...
but this one doesn't:
firstly
test(someValue: 2)
.then
let dd = 1
return test(someValue: dd)
.catch error in
...
swift promisekit
add a comment |
Just started with PromiseKit and running into a weird
compile problem:
- with firstly: Ambiguous reference to member 'firstly(execute:)' ()
- without firstly: Unable to infer complex closure return type; add explicit
Not sure what I am doing wrong here.
Promise
func test(someValue: Int) -> Promise<Void>
return Promise seal in
// do something with someValue
seal.fulfill(())
This works:
firstly
test(someValue: 2)
.then
test(someValue: 1)
.catch error in
...
but this one doesn't:
firstly
test(someValue: 2)
.then
let dd = 1
return test(someValue: dd)
.catch error in
...
swift promisekit
add a comment |
Just started with PromiseKit and running into a weird
compile problem:
- with firstly: Ambiguous reference to member 'firstly(execute:)' ()
- without firstly: Unable to infer complex closure return type; add explicit
Not sure what I am doing wrong here.
Promise
func test(someValue: Int) -> Promise<Void>
return Promise seal in
// do something with someValue
seal.fulfill(())
This works:
firstly
test(someValue: 2)
.then
test(someValue: 1)
.catch error in
...
but this one doesn't:
firstly
test(someValue: 2)
.then
let dd = 1
return test(someValue: dd)
.catch error in
...
swift promisekit
Just started with PromiseKit and running into a weird
compile problem:
- with firstly: Ambiguous reference to member 'firstly(execute:)' ()
- without firstly: Unable to infer complex closure return type; add explicit
Not sure what I am doing wrong here.
Promise
func test(someValue: Int) -> Promise<Void>
return Promise seal in
// do something with someValue
seal.fulfill(())
This works:
firstly
test(someValue: 2)
.then
test(someValue: 1)
.catch error in
...
but this one doesn't:
firstly
test(someValue: 2)
.then
let dd = 1
return test(someValue: dd)
.catch error in
...
swift promisekit
swift promisekit
asked Mar 22 at 23:07
MarkusMarkus
2771315
2771315
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I've been using Promises quite a bit lately and I've run into similar errors, seems like sometimes all the closures and generics get the best of the compiler.
What I've found is that you should always have a done
call if you have a catch
call, add it right before the catch
. done
means you won't be chaining your promise any more and you can then use a PKFinalizer
, like the catch
call is.
And if your promises have parameters you're not using, make sure to add _ in
on your next then
/done
call, or you can add a asVoid()
call in between, which discards the result.
EDIT:
This week I also had an error where adding an extra line to the closure made it fail. Since what I was doing was converting one promise into multiple promises, I used flatMapThen
. There are several methods on Promise
that you can use for different results. You can use get
if you want to store the result from a promise and continue, or map if you want to convert the result into another type.
For example, I would translate your failing error into this
firstly
test(someValue: 2)
.map
1
.then
test(someValue: $0)
.done
print("success")
.catch error in
...
I followed your suggestions, but the example above still doesn't compile. :(
– Markus
Mar 23 at 0:23
@Markus I added some more info to my answer
– EmilioPelaez
Mar 23 at 0:42
1
Thank you! That's a great work around, I spent the entire afternoon trying to get it to work, should have posted sooner ;)
– Markus
Mar 23 at 1:41
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308895%2fpromisekit-cant-call-custom-code-between-then-handlers%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I've been using Promises quite a bit lately and I've run into similar errors, seems like sometimes all the closures and generics get the best of the compiler.
What I've found is that you should always have a done
call if you have a catch
call, add it right before the catch
. done
means you won't be chaining your promise any more and you can then use a PKFinalizer
, like the catch
call is.
And if your promises have parameters you're not using, make sure to add _ in
on your next then
/done
call, or you can add a asVoid()
call in between, which discards the result.
EDIT:
This week I also had an error where adding an extra line to the closure made it fail. Since what I was doing was converting one promise into multiple promises, I used flatMapThen
. There are several methods on Promise
that you can use for different results. You can use get
if you want to store the result from a promise and continue, or map if you want to convert the result into another type.
For example, I would translate your failing error into this
firstly
test(someValue: 2)
.map
1
.then
test(someValue: $0)
.done
print("success")
.catch error in
...
I followed your suggestions, but the example above still doesn't compile. :(
– Markus
Mar 23 at 0:23
@Markus I added some more info to my answer
– EmilioPelaez
Mar 23 at 0:42
1
Thank you! That's a great work around, I spent the entire afternoon trying to get it to work, should have posted sooner ;)
– Markus
Mar 23 at 1:41
add a comment |
I've been using Promises quite a bit lately and I've run into similar errors, seems like sometimes all the closures and generics get the best of the compiler.
What I've found is that you should always have a done
call if you have a catch
call, add it right before the catch
. done
means you won't be chaining your promise any more and you can then use a PKFinalizer
, like the catch
call is.
And if your promises have parameters you're not using, make sure to add _ in
on your next then
/done
call, or you can add a asVoid()
call in between, which discards the result.
EDIT:
This week I also had an error where adding an extra line to the closure made it fail. Since what I was doing was converting one promise into multiple promises, I used flatMapThen
. There are several methods on Promise
that you can use for different results. You can use get
if you want to store the result from a promise and continue, or map if you want to convert the result into another type.
For example, I would translate your failing error into this
firstly
test(someValue: 2)
.map
1
.then
test(someValue: $0)
.done
print("success")
.catch error in
...
I followed your suggestions, but the example above still doesn't compile. :(
– Markus
Mar 23 at 0:23
@Markus I added some more info to my answer
– EmilioPelaez
Mar 23 at 0:42
1
Thank you! That's a great work around, I spent the entire afternoon trying to get it to work, should have posted sooner ;)
– Markus
Mar 23 at 1:41
add a comment |
I've been using Promises quite a bit lately and I've run into similar errors, seems like sometimes all the closures and generics get the best of the compiler.
What I've found is that you should always have a done
call if you have a catch
call, add it right before the catch
. done
means you won't be chaining your promise any more and you can then use a PKFinalizer
, like the catch
call is.
And if your promises have parameters you're not using, make sure to add _ in
on your next then
/done
call, or you can add a asVoid()
call in between, which discards the result.
EDIT:
This week I also had an error where adding an extra line to the closure made it fail. Since what I was doing was converting one promise into multiple promises, I used flatMapThen
. There are several methods on Promise
that you can use for different results. You can use get
if you want to store the result from a promise and continue, or map if you want to convert the result into another type.
For example, I would translate your failing error into this
firstly
test(someValue: 2)
.map
1
.then
test(someValue: $0)
.done
print("success")
.catch error in
...
I've been using Promises quite a bit lately and I've run into similar errors, seems like sometimes all the closures and generics get the best of the compiler.
What I've found is that you should always have a done
call if you have a catch
call, add it right before the catch
. done
means you won't be chaining your promise any more and you can then use a PKFinalizer
, like the catch
call is.
And if your promises have parameters you're not using, make sure to add _ in
on your next then
/done
call, or you can add a asVoid()
call in between, which discards the result.
EDIT:
This week I also had an error where adding an extra line to the closure made it fail. Since what I was doing was converting one promise into multiple promises, I used flatMapThen
. There are several methods on Promise
that you can use for different results. You can use get
if you want to store the result from a promise and continue, or map if you want to convert the result into another type.
For example, I would translate your failing error into this
firstly
test(someValue: 2)
.map
1
.then
test(someValue: $0)
.done
print("success")
.catch error in
...
edited Mar 23 at 0:42
answered Mar 22 at 23:14
EmilioPelaezEmilioPelaez
9,62032536
9,62032536
I followed your suggestions, but the example above still doesn't compile. :(
– Markus
Mar 23 at 0:23
@Markus I added some more info to my answer
– EmilioPelaez
Mar 23 at 0:42
1
Thank you! That's a great work around, I spent the entire afternoon trying to get it to work, should have posted sooner ;)
– Markus
Mar 23 at 1:41
add a comment |
I followed your suggestions, but the example above still doesn't compile. :(
– Markus
Mar 23 at 0:23
@Markus I added some more info to my answer
– EmilioPelaez
Mar 23 at 0:42
1
Thank you! That's a great work around, I spent the entire afternoon trying to get it to work, should have posted sooner ;)
– Markus
Mar 23 at 1:41
I followed your suggestions, but the example above still doesn't compile. :(
– Markus
Mar 23 at 0:23
I followed your suggestions, but the example above still doesn't compile. :(
– Markus
Mar 23 at 0:23
@Markus I added some more info to my answer
– EmilioPelaez
Mar 23 at 0:42
@Markus I added some more info to my answer
– EmilioPelaez
Mar 23 at 0:42
1
1
Thank you! That's a great work around, I spent the entire afternoon trying to get it to work, should have posted sooner ;)
– Markus
Mar 23 at 1:41
Thank you! That's a great work around, I spent the entire afternoon trying to get it to work, should have posted sooner ;)
– Markus
Mar 23 at 1:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308895%2fpromisekit-cant-call-custom-code-between-then-handlers%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown