Introduction

This blog is mainly focused on SharePoint
I will use this to store and share all the tips and tricks about SharePoint and the related products
List of all posts

Assynchronous functions in javascript for Metro Application


Topic Assynchronous functions in javascript for Metro Application
OutputA sample pair of functions

Step Description
1 Create the assynchronous function that you will call later
    function assynchrone_function() {
        return new WinJS.Promise(function (Jsonoutput) {
            var entrainementJSON;
   ...
   do the assync stuff here
   ...
            Jsonoutput(entrainementJSON);
        })

    }
2 Call your function, waiting that it's done before using the return
  var promise = assynchrone_function();
    promise.then(function (data) {
 ...
 use the data
 ...
    });

No comments:

Post a Comment

by Category