Promise Object
Presenter: Nirmal Hota, Mindfire Solutions
Date: 21/02/2014
About Me
MCTS : .NET Framework 4, Web Applications
MCTS : MS Dynamics CRM 2011 Customization and Configuration
MCTS : Microsoft Dynamics CRM 2011 Applications
TCAD : 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/104872959343373237226
Blog : http://nirmalhota.blogspot.in/
Skype : mfsi_nirmal
Contact me in :
Email : nirmalh@mindfiresolutions.com | nirmalhota@gmail.com
Agenda
>> What is a promise
>> How it works
>> Advantages of promise
>> Real life implementation (Demo)
>> Q & A
>> Some frequently used methods
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”
How it works
Application
Give me stuffs (via XHR call)
MoveNext
Promisestogetback
Search
I will manipulate
the stuff if I get it
HereisyourStuff
Got it :)
Let's manipulate
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
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
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
Real life implementation
Demo
Question and
Answer
Thank you
www.mindfiresolutions.com
https://www.facebook.com/MindfireSolutions
http://www.linkedin.com/company/mindfire-solutions
http://twitter.com/mindfires

Promise Object in Windows Store App

  • 1.
    Promise Object Presenter: NirmalHota, Mindfire Solutions Date: 21/02/2014
  • 2.
    About Me MCTS :.NET Framework 4, Web Applications MCTS : MS Dynamics CRM 2011 Customization and Configuration MCTS : Microsoft Dynamics CRM 2011 Applications TCAD : 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/104872959343373237226 Blog : http://nirmalhota.blogspot.in/ Skype : mfsi_nirmal Contact me in : Email : nirmalh@mindfiresolutions.com | nirmalhota@gmail.com
  • 3.
    Agenda >> What isa promise >> How it works >> Advantages of promise >> Real life implementation (Demo) >> Q & A >> Some frequently used methods
  • 4.
    What is apromise >> Schedule work for future >> Asynchronous programming approach >> Runs in background thread >> Foreground works without blocking >> Methods exposed by convention ends with “Async”
  • 5.
    How it works Application Giveme stuffs (via XHR call) MoveNext Promisestogetback Search I will manipulate the stuff if I get it HereisyourStuff Got it :) Let's manipulate
  • 6.
    Some frequently usedMethods >> 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
  • 7.
    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
  • 8.
    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
  • 9.
  • 10.
  • 11.
  • 12.