Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Deferred object in soy template

Benson Ngoy April 13, 2015

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

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Adam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 19, 2015

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

Benson Ngoy April 20, 2015

Thanks for the answer Adam. Very useful. Benson

Adam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 26, 2015

Cheers! FYI: I've created an issue for adding async support to client-web-panels - https://jira.atlassian.com/browse/STASH-7330

TAGS
AUG Leaders

Atlassian Community Events