How to make Q.js (/libs/sightly/js/3rd-party/q.js) Synchronous ? | Community
Skip to main content
Level 4
August 9, 2016

How to make Q.js (/libs/sightly/js/3rd-party/q.js) Synchronous ?

  • August 9, 2016
  • 1 reply
  • 1561 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

smacdonald2008
Level 10
August 9, 2016

It is not recommended to change content under /libs. I would file a ticket on this. Support will tell you what files under /libs you can change,  

user00725Author
Level 4
August 9, 2016

Thanks Scott!

We have not changed the iparsys present in libs folder(/libs/wcm/foundation/components/iparsys). We made an overlay of iparsys under /apps and adding our custom logic.

 

Regards