Hello All,
we are customizing the sightly version of ipasys as per our custom requirements. But due to Q.js asynchronous behaviour, we are facing below issue.
Below is a sample piece of code from our par.js of sightly iparsys.
var parsys = new ParagraphSystem(parResource, undefined, false);
parsys.getParagraphs().then(function (paragraphs) {
for (var parIdx = 0 ; parIdx < paragraphs.length ; parIdx++) {
var currentPar = paragraphs[parIdx];
// Begin - Our custom logic code
ResourceUtils.getResource(currentPar.resourcePath).then(function (paraResource) {
ResourceUtils.getContainingPage(granite.resource).then(function (containingPage) {
var currentPagePath = containingPage.path+"/jcr:content";
ResourceUtils.getResource(currentPagePath).then(function (currentPageResource) {
});
});
});
// End - Our custom logic code
}
Problem facing:- the outer for loop in the above code snippet gets executed before it is executing the inner functions, because of which we couldt able to perform the custom logic on each paragragh from the parent parsys.
How we can make this execution synchronous instead of asynchronous?
Thanks in advance