Promise integration #3234
Unanswered
kennyjwilli
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I remember there where some tricky edge cases with this async POC but I don't remember the details, see #2665 (comment) It would be interesting to pick up async support again BTW :) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am interested in integrating the Promise POC into my application using mathjs. Specifically, I would like to write an expression that concatenates a string together with a value returned from a promise-returning function. e.g., I would like to do something like this.
I have taken the POC code and written an example JSFiddle here. The short is, it doesn't seem to exactly work, and I'd love some help understand why, and if it is possible to fix. A basic example, similar to the POC example does work.
If I make the example slightly more complex by, say, having getDelayedResult return a number that I cast to a string, the promise gets embedded in the string.
The example code wraps the
format
function in the same promise resolving code asconcat
, but it does not seem to work forformat
for some reason. I thought it could be due to the nesting (e.g., concat -> format -> getDelayedResult), but removing the outerconcat
shows that it is unique toformat
.And the same occurs with
string
.And just for completeness, I also tried with
format
with an object param. No dice.Any thoughts on what's going on here and how I may be able to fix/workaround this?
Update: I found an interesting workaround -- JSFiddle. Essentially, if you update the type signature for the promise factory to
...Promise
, it will work for some of the examples.Beta Was this translation helpful? Give feedback.
All reactions