You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using runfunction in FunctionPlugin for showing API result. but it not working as expected due to return executed before the api response.
SO I used to promise inside the fn param but it showing this error
ERROR:
Argument of type ‘(result: any) => Promise’ is not assignable to parameter of type ‘(…arg: any) => InterpreterValue’.
Type ‘Promise’ is not assignable to type ‘InterpreterValue’.ts(2345)
Steps to reproduce
return this.runFunction(
ast.args,
state,
this.metadata("VLOOKUPSHEETFN"),
(param) => {
let item = this.paramFn();
console.log("skjdbvds", item);
return new Promise((resolve, reject) => {
return item = Api call result
});
Hi, @callmehero. Thanks for your feedback. HyperFormula does not support asynchronous custom functions at its current development stage. We discussed this idea a while ago, but at the moment, we prioritize bug and interoperability fixes, so this feature is not on our immediate roadmap.
right now, the easiest way to achieve synchronicity is in the user code outside HyperFormula. I mean a two-step strategy, in which a function like SHARE_PRICE("AMZN") synchronously resolves to a value from cache (or gives an error if the cache is empty) while asynchronously fetching the current value. When fetching is done, update the cache and reevaluate getCellValue/getSheetValues.
In your case, I think you can try this approach:
Fetch data from API every X minutes and store it in the Javascript object (cache).
Custom function VLOOKUPSHEETFN reads data from the cache object and returns it.
Refresh HyperFormula every time a cache value change is detected. 2 things might be helpful for that:
Hi, @callmehero. Thanks for your feedback. HyperFormula does not support asynchronous custom functions at its current development stage. We discussed this idea a while ago, but at the moment, we prioritize bug and interoperability fixes, so this feature is not on our immediate roadmap.
right now, the easiest way to achieve synchronicity is in the user code outside HyperFormula. I mean a two-step strategy, in which a function like SHARE_PRICE("AMZN") synchronously resolves to a value from cache (or gives an error if the cache is empty) while asynchronously fetching the current value. When fetching is done, update the cache and reevaluate getCellValue/getSheetValues.
In your case, I think you can try this approach:
Fetch data from API every X minutes and store it in the Javascript object (cache).
Custom function VLOOKUPSHEETFN reads data from the cache object and returns it.
Refresh HyperFormula every time a cache value change is detected. 2 things might be helpful for that:
Thanks sequba - would there be a way to reference local data in a custom formula in React? I was trying to follow the documentation - wasn't sure how to reference variables in the formula that were not the input variables.
The current solution only deals with async cells that do not depend on other async cells. If this were to be integrated with Handsontable, is there a hook that gets invoked after rebuildAndRecalculate() is done?
If the issue you are facing relates to the integration between HyperFormula and Handsontable, please contact us at support@handsontable.com with implementation details. We'll do our best to help.
Activity
sequba commentedon Dec 7, 2022
Hi, @callmehero. Thanks for your feedback. HyperFormula does not support asynchronous custom functions at its current development stage. We discussed this idea a while ago, but at the moment, we prioritize bug and interoperability fixes, so this feature is not on our immediate roadmap.
But, as @warpech wrote in #9 (comment):
In your case, I think you can try this approach:
VLOOKUPSHEETFNreads data from the cache object and returns it.VLOOKUPSHEETFNfunction volatileDoes it make sense for your use case?
sequba commentedon Dec 13, 2022
Closing. @callmehero, if you have any further questions related to this issue, reopen it, please.
abhii-bit commentedon Feb 13, 2023
I have a question related to this:
I want
Thanks sequba - would there be a way to reference local data in a custom formula in React? I was trying to follow the documentation - wasn't sure how to reference variables in the formula that were not the input variables.
Grateful for your assistance.
AMBudnik commentedon Feb 14, 2023
Hi @abhii-bit! @sequba answered the same subject here #808 (reply in thread)
If you'd have any further questions, please let us know.
sequba commentedon Apr 12, 2024
@abhii-bit @callmehero We have just released HyperFormula 2.7.0 which adds a context configuration parameter that can be used to reference local data in a custom formula.
sandzone commentedon Jun 21, 2024
The current solution only deals with async cells that do not depend on other async cells. If this were to be integrated with Handsontable, is there a hook that gets invoked after rebuildAndRecalculate() is done?
AMBudnik commentedon Jun 26, 2024
Hi @sandzone
We keep this board only for HyperFormula issues.
If the issue you are facing relates to the integration between HyperFormula and Handsontable, please contact us at support@handsontable.com with implementation details. We'll do our best to help.