Async patterns in javascript

Preview:

Citation preview

Fulfill the promise Async patterns with javascript Ran Wahle

A little about myself

Fullstack developer at Global-E Enthusiastic front-end developer Poor UI designer

What will we see today?

Using Events and good old XHR Callbacks with Socket.IO Promise patterns (and standards) Observables Iterators & generators Async / AWAIT Angular 2 and async

Using Events

• Trigger

• Handle

Socket.IO Events

.on(‘topic’, hander) .emit(‘topic’, args)

Promise patterns

Used for one time callback Has many implementations

jQuery.AJAX , angularJs, backbone & more

Promise creation demo

Es2015 promise

One standard (No more “Success”) Native javascript implementation Native support in new APIs

Using Fetch API

Generators & Iterrators

Using array methods asynchronously function* yield

ES2015 iterators

TS async await

Writing asynchronously with “synchronous” syntax await keyword “turns” a promise to its resolved value

TS Async / Await

Lets wrap

Events Promise implementation for ES5 Promises in ES6 Iterators & Generators async & await (TS)

Thanks

Ran Wahlehttp://blogs.microsoft.co.il/ranwTwitter: @ranwahleRan.wahle@gmail.comLinkedin : https://il.linkedin.com/in/ranwahle