Promise Object in Windows Store App
-
Upload
mindfire-solutions -
Category
Software
-
view
306 -
download
0
description
Transcript of Promise Object in Windows Store App
![Page 1: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/1.jpg)
Promise Object
Presenter: Nirmal Hota, Mindfire SolutionsDate: 21/02/2014
![Page 2: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/2.jpg)
About MeMCTS : .NET Framework 4, Web ApplicationsMCTS : MS Dynamics CRM 2011 Customization and ConfigurationMCTS : Microsoft Dynamics CRM 2011 ApplicationsTCAD : Titanium Certified Application Developer
MS Dynamics CRM, Commerce Server, .Net, WinJS, PhoneGap, Titanium, Xamarin
My Key Skills
Connect me in :Facebook : http://www.facebook.com/nirmal.hota.14 Twitter : http://twitter.com/nirmalhota LinkedIn : http://in.linkedin.com/in/nirmalhota Google+ : https://plus.google.com/104872959343373237226Blog : http://nirmalhota.blogspot.in/ Skype : mfsi_nirmal
Contact me in :Email : [email protected] | [email protected]
![Page 3: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/3.jpg)
Agenda
>> What is a promise
>> How it works
>> Advantages of promise
>> Real life implementation (Demo)
>> Q & A
>> Some frequently used methods
![Page 4: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/4.jpg)
What is a promise
>> Schedule work for future
>> Asynchronous programming approach
>> Runs in background thread
>> Foreground works without blocking
>> Methods exposed by convention ends with “Async”
![Page 5: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/5.jpg)
How it works
Application
Give me stuffs (via XHR call)
Move N
ext
Promises to get back
Search
I will manipulate the stuff if I get it
Here is your StuffGot it :)
Let's manipulate
![Page 6: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/6.jpg)
Some frequently used Methods
>> then : Allows to define tasks to be done after promise fulfilled.
>> done : Allows to define tasks to be done after promise fulfilled.
>> any : Allows to define tasks to be done after any of the task performed among a set of promises.
>> join : Allows to define tasks to be done after all of the tasks performed among a set of promises.
>> cancel : Allows to cancel an in progress promise
![Page 7: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/7.jpg)
then vs done>> Both of them are used after the completion of promised task
>> Both the methods takes the same kind of parameters completed, error and in progress handlers
>> “then” returns a promise object where as “done” returns an undefined
>> In case any exception occurred in the promised block, “then” puts the error in the promise object and return it to outside. But “done” throws the same to outside as a normal exception. So better place for “done” is at the end of the promise chain
![Page 8: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/8.jpg)
Advantages of promise
>> No blocking of main thread for long running XHR calls. This can be handled in the background
>> Ability to define the tasks after a long running XHR is over
>> Can chain multiple calls
>> Tasks can be defined to be done after the completion of multiple parallel processes or any process out the set processes
![Page 9: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/9.jpg)
Real life implementation
Demo
![Page 10: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/10.jpg)
Question and Answer
![Page 11: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/11.jpg)
Thank you
![Page 12: Promise Object in Windows Store App](https://reader034.fdocuments.us/reader034/viewer/2022052522/554f405db4c905471e8b4d0c/html5/thumbnails/12.jpg)
www.mindfiresolutions.com
https://www.facebook.com/MindfireSolutions
http://www.linkedin.com/company/mindfire-solutions
http://twitter.com/mindfires