using promise patterns with javascript, jquery, and the sharepoint 2013 app model doug hemminger...

24
Using Promise Patterns with JavaScript, jQuery, and the SharePoint 2013 App Model Doug Hemminger SharePoint Solutions Architect, Protiviti

Upload: alexandrina-lester

Post on 11-Jan-2016

226 views

Category:

Documents


0 download

TRANSCRIPT

Using Promise Patterns with JavaScript, jQuery, and the SharePoint 2013 App ModelDoug HemmingerSharePoint Solutions Architect, Protiviti

About MeI am a Chicago-based Microsoft SharePoint Server MVP and a SharePoint Solution Architect for Protiviti

Chica

go

E-mail: [email protected]

Twitter: @DougHemminger

Blog: www.SharePointDoug.com

Contact Me

Agenda

• SharePoint 2013 App Primer

• JavaScript “Function” Primer

• Asynchronous Patterns in JavaScript

SharePoint 2013 App Primer

Apps for SharePoint are web applications that extend the capabilities of SharePoint

App Shapes

Terminology

Host Web – A SharePoint website where the app is installed and surfaced to the user.

App Web – An isolated SharePoint web site on the SharePoint app domain that hosts SharePoint components used in the app

Hosting Architectures

SharePoint Hosted – App is hosted by SharePoint

Provider Hosted – App is hosted on a dedicated server either on-premises or on a third party hosting service

Architecture Overview

SharePoint-hosted Apps

Runs on an isolated app domain of the SharePoint farm

Authorized using the privileges of the signed in user

Can only use JavaScript and HTML- No server side code

Provider-hosted Apps

Runs on a dedicated server or hosting service (not in SharePoint)

Authorization is through OAuth or the JavaScript cross-domain library

Can use any language supported by the web server or hosting service

JavaScript Function Primer

JavaScript Functions

Functions are Objects in JavaScript. Essentially they are strings of JavaScript code.

Asynchronous Patterns in JavaScript

Asynchronous Patterns

Callbacks

Events

Promises

Callbacks

A callback is a function that is passed to another function as a parameter and somehow affects the flow of execution

Functions are Objects in JavaScript

Callback

Callback Demo

Promises

A promise represents the eventual value returned from the single completion of an operation.

Three states

• Unfullfilled

• Fulfilled

• Rejected

Promises

In jQuery the Promise pattern can be used with $.when(object) where object is a deferred object or a promise

Promises Demo

Thank You!

23

ResourcesTitle Url

Choose patterns for developing and hosting your app for SharePoint

http://msdn.microsoft.com/en-us/library/office/fp179887(v=office.15).aspx

Host webs, app webs, and SharePoint components in SharePoint 2013

http://msdn.microsoft.com/en-us/library/office/fp179925(v=office.15).aspx

Apps for Office and SharePoint Blog http://blogs.msdn.com/b/officeapps/

Showcase: Contoso Incubation Search App http://msdn.microsoft.com/en-US/office/dn594490

Asynchronous Programming in JavaScript with “Promises”

http://blogs.msdn.com/b/ie/archive/2011/09/11/asynchronous-programming-in-javascript-with-promises.aspx

Promise Patterns http://modernjavascript.blogspot.com/2013/09/promise-patterns.html

Understand JavaScript callback functions and use them

http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/

24

ResourcesTitle Url

Understanding Callbacks in JavaScript http://recurial.com/programming/understanding-callback-functions-in-javascript/