Expand my Community achievements bar.

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

Avatar

Level 4

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

2 Replies

Avatar

Level 10

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,  

Avatar

Level 4

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