Hi,
I am writing a plugin which uses a client-web-panel, featuring client-context-provider.
The client-context-provider JS downloads some resources asynchronously for which I used a deferred object.
I would like to return that deferred object to the Soy template and resolve it when it is ready.
Is there a way to do that? Or a clean way to wait for the deferred object to resolve in the JS before returning processed data to the Soy template?
Thanks,
Benson
Community moderators have prevented the ability to post new answers.
Hi Benson,
There currently isn't a way to do that, though it's something we'd like to add in the future (probably by letting you return a Promise for the context instead of the actual context).
Your best option for now is to add an ID to your HTML element, and re-render it when your data arrives. E.g.
function contextProvider() { getData().then(function(data) { $('#my-thing').replaceWith(the.soy.template(data)) }); return {}; // synchronous data - your Soy template has to handle not being given params }
Sorry for a less than ideal answer.
Adam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cheers! FYI: I've created an issue for adding async support to client-web-panels - https://jira.atlassian.com/browse/STASH-7330
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.