SlideShare a Scribd company logo
Developing Async Sense
Nemanja Stojanovic @nem035
Inspirations
Kyle Simpson (@getify) - YDKJS
Jake Archibald (@jaffathecake) - html5rocks, Google
Douglas Crockford - JavaScript The Good Parts
💡❓🤔 ���
Why did that not
work?
W
hy did that work?
I get it !!!

Take that JavaScript
What is Async?
Sync is two things happening chronologically one after the other
Make 🍞
⏲ for it
Cut 🍅
Async is two things happening chronologically independent of one another
Make 🍞
Cut 🍅
⏲ for it

Recommended for you

ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing Era

We've entered the Ambient Computing Era and JavaScript is its dominant programing language, But a new computing era needs a new and better JavaScript. It's called ECMAScript 6 and it's about to become the new JavaScript standard. Why do we need it? Why did it take so long? What's in it? When can you use it? Answers will be given.

javascript standardsecmascript 6ecmascript
Maintainable JavaScript 2011
Maintainable JavaScript 2011Maintainable JavaScript 2011
Maintainable JavaScript 2011

Writing JavaScript as a hobby and writing JavaScript as a job are two very different things. Learn some common practices for making your JavaScript friendly to a team environment.

javascriptnzakasbest practices
Rxjs kyivjs 2015
Rxjs kyivjs 2015Rxjs kyivjs 2015
Rxjs kyivjs 2015

Rx.js allows for asynchronous programming using Observables that provide a stream of multiple values over time. The document discusses how Observables can be created from events, combined using operators like map, filter, and flatMap, and subscribed to in order to handle the stream of values. A drag and drop example is provided that creates an Observable stream of mouse drag events by combining mouse down, mouse move, and mouse up event streams. This allows treating the sequence of mouse events as a collection that can be transformed before handling the drag behavior.

rx.js
Developing Async Sense
First attempt at async code
Treads
One piece of code -> Simultaneous code execution, sharing resources
Treads Sandwich
One piece of code -> Simultaneous code execution
if not 🍞, make 🍞
if not 🍅, cut 🍅
if not 🍞, make 🍞
if not 🍅, cut 🍅
🍞🍅
You Your Clone
Possible outcomes
🍞🍞🍅
🍞🍅🍅
🍞🍞🍅🍅

Recommended for you

Streams in Node.js
Streams in Node.jsStreams in Node.js
Streams in Node.js

Streams allow connecting programs like connecting garden hoses. They provide a way to pipe input through multiple steps to an output. There are different types of streams like readable, writable, duplex, and transform streams. Common uses of streams in Node.js include http, fs, child processes, tcp, and zlib. Streams are event emitters that can be used to process data incrementally instead of all at once.

streamsapinode.js
JavaScript Async for Effortless UX
JavaScript Async for Effortless UXJavaScript Async for Effortless UX
JavaScript Async for Effortless UX

Page freeze, glitchy animation, and slow scrolling. They follow us everywhere, and we'd like them to stop. This talk will get to the bottom of these issues by delving into the Javascript engine and concepts like task, call-stack, and event-loops. I will also introduce several ways to tackle these problems and walk you through a demo to help you understand.

javascriptuxeventloop
Deep Dive into Zone.JS
Deep Dive into Zone.JSDeep Dive into Zone.JS
Deep Dive into Zone.JS

This document provides an in-depth overview of Zone.js and how it works. It discusses: - The event loop and how Zone.js intercepts asynchronous tasks like setTimeout and promises. - How zones provide execution contexts and how Zone.js uses zones to observe and control code execution. - How zones can be forked to create child zones and intercepted using hooks to monitor asynchronous tasks. - How Zone.js monkey patches browser APIs and schedules tasks through the current zone rather than calling APIs directly.

angulartypescriptzonejs
arr.length
arr.push('b');
arr.length
arr.push('a');
arr.lengtharr.length
arr.push('a');arr.push('a');	
if	(arr.length	==	1)	{	
		arr.push('b');	
}	
arr.push('a');arr.push('a');	
if	(arr.length	==	1)	{	
		arr.push('b');	
}	
arr.push('a');
arr.push('b');
arr.length
arr.push('a');
Possibility 1 Possibility 2
[													] [								]'a''a', 'b', 'a', 'a'
arr.push('a');	
if	(arr.length	==	1)	{	
		arr.push('b');	
}	
arr.length
arr.push('a');arr.push('a');	
if	(arr.length	==	1)	{	
		arr.push('b');	
}	
Possibility 3
[													]'a','a', 'b'
Problems with Threads
- Data Corruption Risks
Shared Memory -> Races who gets to the shared data first
Deadlocks -> Two (or more) threads waiting on each other
- System gets completely blocked
Problems with Threads
Confusing flow control and timing issues
Difficult to reason about
Problems with Threads

Recommended for you

Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...

SurfaceViews allow drawing to a separate thread to achieve realtime performance. Key aspects include: - Driving the SurfaceView with a thread that locks and draws to the canvas in a loop. - Using input buffering and object pooling to efficiently process touch/key events from the main thread. - Employing various timing and drawing techniques like fixed scaling to optimize for performance. Managing the SurfaceView lifecycle to ensure the drawing thread starts and stops appropriately.

mobile application developmentdroidconandroid
Real-Time Web Apps & Symfony. What are your options?
Real-Time Web Apps & Symfony. What are your options?Real-Time Web Apps & Symfony. What are your options?
Real-Time Web Apps & Symfony. What are your options?

This document discusses options for building real-time web applications with Symfony. It covers existing solutions like ReactPHP, Ratchet, Faye and Pusher that provide real-time functionality. It also considers factors like programming language, application functionality, architecture, and whether to use a self-hosted or hosted solution. Example architectures are presented using Symfony with Ratchet and Faye. The document aims to help developers choose the right real-time solution for their needs.

phpscalingsymfony
Real world functional reactive programming
Real world functional reactive programmingReal world functional reactive programming
Real world functional reactive programming

FRP is about programming with asynchronous data streams declaratively. Reactive programming treats everything as an asynchronous data stream. FRP uses concepts from functional programming like immutable data and first class functions. The key abstraction in FRP is IObservable which represents a stream of events or values over time. FRP is useful for handling events, stateful applications, and incoming data streams from sources like the file system, sensors, or HTTP requests.

programmingfrpfunctional
Tread-safe code
Mutual Exclusion (Mutex)
- Semaphores, monitors, synchronization
Mutex is a program object that prevents simultaneous
access to a shared resource.
- Each critical section is executed once per thread
Tread-safe Sandwich
One piece of code -> mutexed code execution
mutex if not 🍞, make 🍞
mutex if not 🍅, cut 🍅
mutex if not 🍞, make 🍞
mutex if not 🍅, cut 🍅
🍞🍅
You Your Clone
Possible outcomes
lock();	//	lock	execution	to	the	current	thread	
arr.push('a');	
if	(arr.length	==	1)	{	
		arr.push('b');	
}	
unlock();	//	free	execution	for	the	next	thread	
Only possible output: [													]'a''a', 'b',
Tread-safe code
JavaScript
Everything runs and shares the same thread:
- JS Engine, DOM, CSS Engine …
Browser has multiple queues (Event, Render, Network…)

and it might perform actions from any of the queues

(depending on priority, efficiency…), but can only do one at a time
Single Threaded

Recommended for you

RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in Depth

Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/2a2Djbp. Gerard Sans explains RxJS' data architecture based on reactive programming, exploring Observables API using RxJS koans and unit tests. RxJS 5 focuses on performance and usability. Filmed at qconlondon.com. Gerard Sans is a multi-talented Computer Science Engineer specialised in Web. He has lived and worked for all sorts of companies in Germany, Brazil, UK and Spain. He enjoys running AngularJS Labs London, mentoring AngularJS students, participating in the community, giving talks and writing technical articles at Medium.

infoqqconqconlondon
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js

This document provides an introduction to Node.js. It discusses why JavaScript can be strange, but explains that JavaScript is relevant as the language of the web. It then discusses what Node.js is and its event-driven, non-blocking architecture. Popular Node.js applications like HTTP servers, REST APIs, and web sockets are mentioned. Examples are provided of building a simple web app with Express and Jade, a REST API with Restify, and using web sockets with Socket.io. The document also discusses using Mongoose with MongoDB for data modeling.

mongodbnode.jsrestify
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scale

This document discusses benchmarks and performance testing of Node.js. It notes that while Node.js can handle over 1 million connections, benchmarks are not that important as other factors like productivity. It explores how to meaningfully measure Node.js performance, compares Node.js to other frameworks like Erlang and Tornado, and argues that benchmarks should reflect real-world use cases rather than simplistic "hello world" tests. The document questions overreliance on benchmarks and emphasizes picking the right tool based on the task.

JavaScript - Single Threaded
Only one thing can happen at a time (Single Call Stack)
Async code runs after the stack is empty
Async code doesn’t block the UI because its processed later
JS Engine
JS Code has the Run-to-Completion semantic
Function code is atomic (once a function starts it has to finish)
That’s why if the CSS Engine wants to repaint but JS is still
running we get jerkiness
Highest priority in the JS Thread
Run-to-Completion
Each Queued task (click event, render, ajax response) is processed
completely
- No other queue task can be processed until current one is finished
Important
If a message takes too long to complete, the web application is unable to
process user interactions (like click or scroll).
Each function runs in full
- No other function can run while another function is running
Why does this matter?
Analogy:

Because being on hold sucks.
Imagine having the customer service call you when they’re available.
Much better, right?
Good UX === Non-Blocking
Who cares?

Recommended for you

WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open web

An introduction to WebGL for OpenGL developers. Topics include current browser support - as of September 2011 - and JavaScript.

gpuwebglhtml5
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js

This document provides an introduction to Node.js, a framework for building scalable server-side applications with asynchronous JavaScript. It discusses what Node.js is, how it uses non-blocking I/O and events to avoid wasting CPU cycles, and how external Node modules help create a full JavaScript stack. Examples are given of using Node modules like Express for building RESTful APIs and Socket.IO for implementing real-time features like chat. Best practices, limitations, debugging techniques and references are also covered.

node.jsnodejsexpress.socket.io
UniRx - Reactive Extensions for Unity(EN)
UniRx - Reactive Extensions for Unity(EN)UniRx - Reactive Extensions for Unity(EN)
UniRx - Reactive Extensions for Unity(EN)

This document introduces UniRx, which brings reactive extensions to Unity using C#. It discusses problems with using coroutines and callbacks for asynchronous code in Unity. UniRx uses IObservable to asynchronously handle network requests, events, and multithreading in a way that is composable, separates concerns, and avoids callback hell. It provides additional methods for Unity like ObservableMonoBehaviour and converting callbacks to observables. The conclusion is that UniRx is better than coroutines or tasks for asynchronous and reactive programming in Unity.

reactive extensionsunitycsharp
How do we not block then?
Callbacks
JS Code
var	one	=	getOneSync();	
getThreeAsync((three)	=>	{		
		alert(three);	
});	
var	two	=	getTwoSync();
var	one	=	getOneSync();	
getThreeAsync((three)	=>	{		
		alert(three);	
});	
var	two	=	getTwoSync();
var	one	=	getOneSync();	
setTimeout((three)	=>	{		
		alert(three);	
});	
var	two	=	getTwoSync();
NOW
LATER
Output?
console.log('A');	
setTimeout(()	=>	{		
		console.log('B');	
},	1000);	
console.log('C');	
Console:

'A'

'C'

'B'
Output?
console.log('A');	
setTimeout(()	=>	{		
		console.log('B');	
},	0);	
console.log('C');	
Console:

'A'

'C'

'B'

Recommended for you

Node.js 0.8 features
Node.js 0.8 featuresNode.js 0.8 features
Node.js 0.8 features

Node version 0.8 includes significant performance improvements and changes to core APIs. It provides up to 10% faster execution speed and up to 4x faster file I/O due to changes in the V8 engine and underlying system calls. Many core Node modules like http, net, and child_processes see major API changes and added functionality. New features like domains and clusters are introduced to make asynchronous code and load distribution across cores easier.

node.jsjavascriptweb design and development
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJava

Intro to RxJava in a non blocking I/O context. My slides tend to make little sense without the talk ;-)

rxjava servlet reactive nonblocking
Asynchronous development in JavaScript
Asynchronous development  in JavaScriptAsynchronous development  in JavaScript
Asynchronous development in JavaScript

Asynchronous JavaScript development allows long-running operations like network requests or file access to occur without blocking the main thread through an event-driven programming model and callback functions. The browser uses an event loop to queue and execute events. While JavaScript can only execute one task at a time, asynchronous functions expose callbacks to handle completed operations. This can lead to "callback hell" where code becomes nested and difficult to follow. Promises and async/await were introduced to simplify asynchronous code by handling callbacks in a cleaner way similar to synchronous code. Web workers also allow true concurrency by running scripts on a separate thread.

javascriptweb development
How does this happen?
Event Loop
Infinitely looping looking for new tasks to execute.
A single iteration is called a tick.
The code executed during a tick is called a task.
Cannot execute a task while either JS code or another task is running
function	eventLoop()	{	
		//	perform	loop	ticks,	"forever"	
		while	(true)	{	
				var	nextTask	=	taskQueue[0];	
				nextTask();	
		}	
}
Event Loop
Tasks are synchronous
Tasks may schedule other tasks in the loop.
Tasks may come from other sources such as user events, 

networking or DOM manipulation.

Recommended for you

Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScript

An easy dive into asynchronous programming and how it works with JavaScript's event loop, queue, and multiple threads.

asynchronousprogrammingjavascript
Event Loop in Javascript
Event Loop in JavascriptEvent Loop in Javascript
Event Loop in Javascript

This document discusses the event loop in JavaScript. It begins by explaining the call stack and memory heap in JavaScript's execution environment. It then discusses how JavaScript is single-threaded and uses an event loop to handle asynchronous tasks and callbacks. Examples are given of how setTimeout is used to illustrate the non-blocking nature of JavaScript and how the event loop processes tasks and callbacks in the queue. It concludes by mentioning how tasks like rendering and animations are handled by the event loop and discusses alternatives like web workers.

javascripteventloop
An opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathonAn opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathon

A talk presenting an opinionated introduction to Node.js, proving a simple introduction to the async model, some common async patterns and some other interesting Node.js tricks.

node.jsasyncdesign patterns
console.log('A');
setTimeout(function	cb()	{	
		console.log('B');	
},	1000);
console.log('C');
Console
Task Queueconsole.log('A');
'A'
console.log('C');
cb()
'C' 'B'
setTimeout(function	cb()	{	
		console.log('B');	
},	1000);
BrowserCall Stack
log('A')setTimeout()log('C')
Wait 1secconsole.log('B');
log('B')
console.log('A');
setTimeout(function	cb()	{	
		console.log('B');	
},	0);
console.log('C');
Console
Task Queueconsole.log('A');
'A'
console.log('C');
cb()
'C' 'B'
setTimeout(function	cb()	{	
		console.log('B');	
},	0);
BrowserCall Stack
log('A')setTimeout()log('C')
Wait .004secconsole.log('B');
log('B')
Wait until 

Stack is Empty
Why is setTimeout(cb,	0) useful?setTimeout(cb,	0)	
Defer code execution until the Call Stack is empty
Add heavy-weight code to the end of the Event Loop
Allow browser to re-render and/or process events 

before executing our code
Example
function	process(data)	{	
		var	chunk	=	data.slice(0,	10);	//	take	first	10	items	
		//...	do	heavy-weight	stuff	with	the	chunk	
		//	stick	this	function	at	the	end	of	the	event	queue	
		setTimeout(()	=>	{	
				//	continue	processing	the	data	after	Call	Stack	is	clear	
				process(data.slice(10))	
		},	0);	
}

Recommended for you

HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?

2014 yılının sonunda sonlandırılması beklenen HTML standardının 5. sürümü çoktandır tarayıcılar tarafından destekleniyor. HTML5 ile gelen Canvas, Websockets ve diğer özelliklerle nasıl daha canlı, daha Flash uygulamalarına benzer, web uygulamaları geliştirebileceğimizi inceledik.

html5ankarajug. murat can alpayflash
A More Flash Like Web?
A More Flash Like Web?A More Flash Like Web?
A More Flash Like Web?

This document provides an overview of HTML5 and its capabilities for building interactive web applications. It discusses the history and development of HTML5, including the roles of the WHATWG and W3C. It also summarizes key HTML5 features such as JavaScript, Canvas, WebSockets, storage options, and emerging 3D capabilities. Throughout, it provides examples of how these features can be used to create games, multimedia experiences, and real-time applications on the modern web.

audiohtml5canvas
Playing With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsPlaying With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.js

node.js is an evented server-side Javascript framework powered by the Google V8 Javascript engine. It is a platform ideal for creating highly scalable web applications. It has the same simplicity of frameworks such as Sinatra, but is designed to be more peformant from the ground up. This performance is achieved by making all network I/O non blocking and all file I/O asynchronous. We will go over how that impacts the development experience, and walk through a simple web application. Javascript is foundational to this type of I/O because it is already evented by design. We will also take a brief look a similar evented frameworks such as ruby`s EventMachine.

node.jsserverjavascript
Callbacks
A callback function is a function which is:
- passed as an argument* to another function, and,
- is invoked after some kind of event.
*Because JS functions are first-class functions
Callbacks
Building blocks of asynchronous JS.
Ok, callbacks are great.



But… are there any problems with them?
Callback Hell
httpGet('/stories/'	+	storyId,	function	(story)	{	
		httpGet(story.chapterUrls[0],	function	(chapter)	{	
				httpGet(chapter.pageUrls[0],	function	(page)	{	
				var	chapterJSON	=	JSON.parse(chapter);	
				displayChapter(chapterJSON);	
		});	
});	
Most known callback issue - Pyramid of doom

Recommended for you

Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...

Salah satu front-end developer GITS Indonesia, Warsono, mengisi workshop di universitas, mengenai Vue.js. Ikuti kami di kanal berikut, agar tidak ketinggalan acara seru: Instagram: @gitsindonesia LinkedIn: GITS Indonesia Website: gits.id

gits indonesiamobile app developmentmobile application development
JavaScript Multithread or Single Thread.pptx
JavaScript Multithread or Single Thread.pptxJavaScript Multithread or Single Thread.pptx
JavaScript Multithread or Single Thread.pptx

The document discusses how JavaScript works and whether it is single-threaded or multi-threaded. It explains that JavaScript is single-threaded, with a single call stack that executes code line by line. Asynchronous functions use callbacks and a callback queue to avoid blocking the main thread. The event loop monitors the call stack and callback queue, executing callbacks when the call stack is empty. This allows for non-blocking behavior through asynchronous functions and Web APIs, even though JavaScript remains a single-threaded language.

javascriptmultithreadingengineering
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men

JavaScript basics JavaScript event loop Ajax and promises DOM interaction JavaScript object orientation Web Workers Useful Microframeworks This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2014. http://www.ivanomalavolta.com

javascripthtml5technology
Pyramid of Doom - Solved?
httpGet('/stories/'	+	storyId,	processStory);	


function	processStory(story)	{	
		httpGet(story.chapterUrls[0],	processChapter);	
}	
function	processChapter(chapter)	{	
		httpGet(chapter.pageUrls[0],	processPage);	
}	
function	processPage(page)	{	
		var	chapterJSON	=	JSON.parse(chapter);	
		displayChapter(chapterJSON);	
}
Is that it?
Turns out… there’s a lot more
Reaction order is difficult to maintain
Error are hard to handle (flow branches on errors)
- Require manual error handling (no try/catch)
Success/Error path logic has to be hardcoded
- Unmaintainable
Non-Sequential
Flow
}
- Require maintaining state in the global scope
Mixing input and output
- Tie up async operation with our reaction to it
And some more…
Being called too many times
Swallowing errors or exceptions
Unreliable Execution
}
No built-in protection against:
Being called too early

Recommended for you

Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine

This document contains information about Ricardo Silva's background and areas of expertise. It includes his degree in Computer Science from ISTEC and MSc in Computation and Medical Instrumentation from ISEP. It also notes that he works as a Software Developer at Shortcut, Lda and maintains a blog and email contact for Node.js topics. The document then covers several JavaScript, Node.js and Websockets topics through examples and explanations in 3 sentences or less each.

node.jsnodejssockets
The evolution of java script asynchronous calls
The evolution of java script asynchronous callsThe evolution of java script asynchronous calls
The evolution of java script asynchronous calls

The document summarizes the evolution of asynchronous calls in JavaScript, from callbacks to promises to async/await. It discusses how callbacks can lead to "callback hell" code that is difficult to read and maintain. Promises were introduced to make asynchronous code flatter and easier to read by chaining operations. Async/await was later added and allows asynchronous code to be written in a synchronous-looking way by using await in async functions. Overall, the document traces the progression from callbacks to promises to async/await in improving the handling of asynchronous operations in JavaScript.

javascriptpromise
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js

Node.js is a JavaScript runtime built on Chrome's V8 engine that allows JavaScript to be run on the server side. It is single-threaded, non-blocking, and asynchronous which means it relies on callbacks and an event loop to handle concurrent operations like I/O instead of blocking threads. The event loop handles callbacks by placing them in a queue to be executed once the current thread is complete. This allows Node.js to handle a large number of concurrent connections efficiently. Some common uses of Node.js include real-time applications, proxies, and chat applications due to its asynchronous nature. It is not well-suited for heavy computation or large web applications.

javascriptnodejsevent loop
Non-Sequential Flow
Callbacks - Getting two values in parallel?
httpGet(url1,	function(res)	{	
		//	here	we	have	value	1	
});	
httpGet(url2,	function(res)	{	
		//	here	we	have	value	2	
});	
function	processValues(value1,	value2)	{	
		//	how	do	we	know	when	we	have	both?	
}
function(res)	{	
		value1	=	res;	
		if	(typeof	value2	!==	'undefined')	{	
				processValues(value1,	value2);	
		}	
var	value1,	value2;	var	value1,	value2;	
httpGet(url1,	function(res)	{	
		value1	=	res;	
		if	(typeof	value2	!==	'undefined')	{	
				processValues(value1,	value2);	
		}	
});	
httpGet(url2,	function(res)	{	
		value2	=	res;	
		if	(typeof	value1	!==	'undefined')	{	
				processValues(value1,	value2);	
		}	
});	
processValues(value1,	value2);
processValues(value1,	value2);
														function(res)	{	
		value2	=	res;	
		if	(typeof	value1	!==	'undefined')	{	
				processValues(value1,	value2);	
		}	
Maintain state externally
Mixing input and output
Repetition (not DRY)
Non-Sequential Flow
processValues(values.value1,	values.value2);
var	values	=	{	value1:	undefined,	value2:	undefined	};	
var	hasValues	=	{	value1:	false,	value2:	false	};	
httpGet(url1,	getRequestHandler('value1'));	
httpGet(url2,	getRequestHandler('value2'));	
function	getRequestHandler(valueNum)	{	
		return	function(res)	{	
				hasValues[valueNum]	=	true;	
				values[valueNum]	=	res;	
					
				if	(hasValues.value1	&&	hasValues.value2)	{	
						processValues(values.value1,	values.value2);	
				}	
		}	
}	
							function(res)	{	
		hasValues[valueNum]	=	true;	
		values[valueNum]	=	res;	
					
		if	(hasValues.value1	&&	hasValues.value2)	{	
				processValues(values.value1,	values.value2);	
		}	
}	
getRequestHandler('value2')
getRequestHandler('value1')
var	values	=	{	value1:	undefined,	value2:	undefined	};	
var	hasValues	=	{	value1:	false,	value2:	false	};
Maintain state externally
Mixing input and output
DRY
Non-Sequential Flow
What if we were getting more than 2
things in parallel?

Recommended for you

Responsive interfaces
Responsive interfacesResponsive interfaces
Responsive interfaces

The document discusses responsive interfaces and how to keep the user interface responsive when executing JavaScript. It explains that the UI thread is used for both drawing updates and running JavaScript, so no updates can happen while JavaScript runs. It recommends keeping JavaScript execution under 50ms to avoid unresponsiveness, and describes using timers and web workers to split processing over multiple ticks to keep the UI responsive.

Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk

These are the original slides from the nodejs talk. I was surprised not find them on slideshare so adding them. The video link is here https://www.youtube.com/watch?v=ztspvPYybIY

javascriptnodejsconcurrency
JavaScript Engines and Event Loop
JavaScript Engines and Event Loop JavaScript Engines and Event Loop
JavaScript Engines and Event Loop

This document discusses JavaScript engines and event loops. It explains key concepts like the call stack, event queue, microtasks vs macrotasks, and how JavaScript creates the illusion of being asynchronous through the event loop. The event loop constantly checks the call stack and queue, executing functions to give the appearance of multithreading on a single thread. Web APIs also provide asynchronous capabilities that interact with the event loop.

javascriptjavascript engineevent loops
var	values	=	{};	
var	hasValues	=	{};	
processValues.apply(

		null,	getAllValues()

);
var	values	=	{};	
var	hasValues	=	{};	
urls.forEach(function(url)	{	
			httpGet(url,	getRequestHandler(url));	
});	
function	getRequestHandler(url)	{	
		return	function(res)	{	
				hasValues[url]	=	true;	
				values[url]	=	res;	
				if	(hasAllValues())	{	
						processValues.apply(

								null,	getAllValues()

						);	
				}	
		}	
}	
function	hasAllValues()	{	
		return	urls.every(function(url)	{	
				return	hasValues[url];	
		});	
}	
function	getAllValues()	{	
		return	urls.map(function(url)	{	
				return	values[url];	
		});	
}	
DRY
Non-Sequential Flow
Maintain state externally
Mixing input and output
Generalized
What if we wanted to make parallel request but process
data as soon as it’s received and in some order?
Let’s say we want to request value1 and value2 at the
same time but process them in order (value1 then value2)
processValue(value2);
value2	=	result;
processValue(value1);
value1	=	result;
value1 received first
1. receive value1
2. process value1
3. receive value2
4. process value2
var	value1,	value2;	
httpGet(url1,	function(res)	{	
		value1	=	result;	
		processValue(value1);	
		if	(typeof	value2	!==	'undefined')	{	
				processValue(value2);	
		}	
});	
httpGet(url2,	function(res)	{	
		value2	=	result;	
			
		if	(typeof	value1	!==	'undefined')	{	
				processValue(value2);	
		}	
});

Recommended for you

Node js lecture
Node js lectureNode js lecture
Node js lecture

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It introduces events and an event queue to handle asynchronous and non-blocking operations. Everything runs as a callback from the event loop. Node.js wraps OS operations in modules to make file, network, and other operations non-blocking and event-driven. It also introduces a module system where each module gets its own private scope. Common patterns in Node.js include using the listener/emitter pattern to handle events and building applications with streams of data.

Performance patterns
Performance patternsPerformance patterns
Performance patterns

The document discusses various patterns and techniques for improving JavaScript performance, including: 1. Loading scripts asynchronously and deferring execution to improve perceived page load times. 2. Using local variables instead of globals to reduce scope chain lookups and improve minification. 3. Caching expensive operations through memoization and reusing initialization code to avoid redundant work. 4. Avoiding direct DOM access in loops to reduce reflows and repaints, such as building up a string instead of multiple innerHTML assignments.

wpojsconfeuoptimization
JavaScript
JavaScriptJavaScript
JavaScript

JavaScript basics JavaScript event loop Ajax and promises DOM interaction JavaScript object orientation Web Workers Useful Microframeworks This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2015. http://www.ivanomalavolta.com

mobile application developmentmobile appsunivaq
processValue(value2);
var	value1,	value2;	
httpGet(url1,	function(res)	{	
		value1	=	result;	
		processValue(value1);	
		if	(typeof	value2	!==	'undefined')	{	
				processValue(value2);	
		}	
});	
httpGet(url2,	function(res)	{	
		value2	=	result;	
			
		if	(typeof	value1	!==	'undefined')	{	
				processValue(value2);	
		}	
});	
value2	=	result;
processValue(value1);
value1	=	result;
value2 received first
1. receive value2
2. receive value1
3. process value1
4. process value2
Can we generalize it?
var	values	=	{};	
var	processed	=	{};
processValue(values[url]);
var	values	=	{};	
var	processed	=	{};	
urls.forEach(function(url)	{	
		httpGet(url,	function(res)	{	
				values[url]	=	res;	
				urls.every(function(url)	{	
						if(values[url])	{	
								if	(!processed[url])	{	
										processValue(values[url]);	
										processed[url]	=	true;	
								}	
						}	
						return	!!processed[url];	
				});	
		});	
});	
Non-Sequential Flow
Maintain state externally
Mixing input and output
DRY
Generalized
sendPurchaseOrder(books[0].url,	function()	{	
});
getBooks(store.booksUrl,	function(books)	{	
				
;	
});
Unreliable
getStore(url,	function	(store)	{	
		
});	
displaySuccessDialog();
Can we guarantee that getStore wont call its callback twice which
would call getBooks twice and then send two purchase orders?
How about if getBooks sometimes returns an invalid url array?

Recommended for you

Kotlin Coroutines and Rx
Kotlin Coroutines and RxKotlin Coroutines and Rx
Kotlin Coroutines and Rx

Kotlin Coroutines is a new killer feature in Kotlin language. What are they, how do we use them, and how do they connect to Reactive programming (Rx)

kotlincoroutinesrx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx

Enhance the top 9 user pain points with effective visual design elements to improve user experience & satisfaction. Learn the best design strategies

#ui visual designrecruitmentux
MVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptxMVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptx

An MVP (Minimum Viable Product) mobile application is a streamlined version of a mobile app that includes only the core features necessary to address the primary needs of its users. The purpose of an MVP is to validate the app concept with minimal resources, gather user feedback, and identify any areas for improvement before investing in a full-scale development. This approach allows businesses to quickly launch their app, test its market viability, and make data-driven decisions for future enhancements, ensuring a higher likelihood of success and user satisfaction.

mvp developmentmvp software developmentmvp mobile application
var	hasExecuted	=	false;	
processValue(res);
var	hasExecuted	=	false;	
httpGet(url,	function(res)	{	
		if	(!hasExecuted)	{	
				hasExecuted	=	true;	
				processValue(res);	
		}	
});	
A callback that runs once
Non-Sequential Flow
Maintain state externally
Mixing input and output
Error Handling
Separate handlers for success and fail cases
$.ajax({	
		success:	function()	{	
				//	...	
		},	
		error:	function()	{	
				//	...	
		}	
})
$.ajax({	
		success:	function()	{	
	},	
		error:	function()	{	


	}	
})	
- Reduces (somewhat) the issue of

Non-Sequential Flow by splitting logic
//	success	path//	...
//	...//	error	path
$.ajax({	
		success:	function()	{	
				
		},	
		error:	function()	{	
					
		}	
})	
Doubles our need for protection

against Unreliable Execution
because now we have two
callbacks to worry about instead of
one
I am unreliable
Me too!
//	Not	called	on	time?	
//	Not	called	at	all?

//	Called	to	many	times?
//	Not	called	on	time?	
//	Not	called	at	all?

//	Called	to	many	times?

Recommended for you

FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)

Free ad-supported streaming takes off! Dive into the projected surge of FAST channels & market size from 2024 to 2027.

fast channelsfree streaming tvott
Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …

Prada Group Reports Strong Growth in First Quarter …

Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies

A captivating AI chatbot PowerPoint presentation is made with a striking backdrop in order to attract a wider audience. Select this template featuring several AI chatbot visuals to boost audience engagement and spontaneity. With the aid of this multi-colored template, you may make a compelling presentation and get extra bonuses. To easily elucidate your ideas, choose a typeface with vibrant colors. You can include your data regarding utilizing the chatbot methodology to the remaining half of the template.

chatbot ppt
What if res is an invalid JSON?
Bloat code with noise by
requiring error handling
logic in every callback
Error Handling
function	getJSON(url,	cb)	{	
		httpGet(url,	function(err,	res)	{	
				if	(err)	{	
						cb(err);	
				}	else	{	
						cb(null,	JSON.parse(res))	
				}	
		});	
}	
Error-first style callbacks
What if cb() throws an error?
function	cb(err,	json)	{	
		throw	Error('Error	within	cb()')	
}	
function	getJSON(url,	cb)	{	
		httpGet(url,	function(err,	res)	{	
				if	(err)	return	cb(err);	
				try	{	
						cb(null,	JSON.parse(res));	
				}	catch(err)	{	
						cb(err);	
				}		
		});	
}	
Error Handling Error-first style callbacks
function	getJSON(url,	cb)	{	
		httpGet(url,	function(err,	res)	{	
				if	(err)	return	cb(err);	
				try	{	
						res	=	JSON.parse(res);	
				}	catch(err)	{	
						return	cb(err);	
				}	
				cb(null,	res);		
		});	
}	
Ok, we are handling errors
Error Handling Error-first style callbacks
But… can we easily
reason about this code?
Non-Sequential Flow Unreliable Execution
Thunks ???
Solutions?

Recommended for you

Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps

Unlock the full potential of your data by effortlessly migrating from PostgreSQL to Snowflake, the leading cloud data warehouse. This comprehensive guide presents an easy-to-follow 8-step process using Estuary Flow, an open-source data operations platform designed to simplify data pipelines. Discover how to seamlessly transfer your PostgreSQL data to Snowflake, leveraging Estuary Flow's intuitive interface and powerful real-time replication capabilities. Harness the power of both platforms to create a robust data ecosystem that drives business intelligence, analytics, and data-driven decision-making. Key Takeaways: 1. Effortless Migration: Learn how to migrate your PostgreSQL data to Snowflake in 8 simple steps, even with limited technical expertise. 2. Real-Time Insights: Achieve near-instantaneous data syncing for up-to-the-minute analytics and reporting. 3. Cost-Effective Solution: Lower your total cost of ownership (TCO) with Estuary Flow's efficient and scalable architecture. 4. Seamless Integration: Combine the strengths of PostgreSQL's transactional power with Snowflake's cloud-native scalability and data warehousing features. Don't miss out on this opportunity to unlock the full potential of your data. Read & Download this comprehensive guide now and embark on a seamless data journey from PostgreSQL to Snowflake with Estuary Flow! Try it Free: https://dashboard.estuary.dev/register

postgresqlsnowflakepostgres to snowflake
Folding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a seriesFolding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a series

The three duality theorems of fold.

duality theorems of foldduality theoremsfold
Attendance Tracking From Paper To Digital
Attendance Tracking From Paper To DigitalAttendance Tracking From Paper To Digital
Attendance Tracking From Paper To Digital

If you are having trouble deciding which time tracker tool is best for you, try "Task Tracker" app. It has numerous features, including the ability to check daily attendance sheet, and other that make team management easier.

time trackerdaily attendance sheettask tracker
Thunks
Wrappers around callbacks
Eliminate time as a concern
Conceptual base for promises
Wrappers around future values
Eliminate time… what?
function(cb)	{	
		if	(typeof	value	===	'undefined')	{	
				callback	=	cb;	
		}	else	{	
				cb(value);	
		}	
}	
function	httpGetThunk(url)	{	
		var	value,	callback;	
			
		httpGet(url,	function(res)	{	
				if	(typeof	callback	===	'undefined')	{	
						value	=	res;	
				}	else	{	
						callback(res);	
				}	
		});	
		return	function(cb)	{	
				if	(typeof	value	===	'undefined')	{	
						callback	=	cb;	
				}	else	{	
						cb(value);	
				}	
		}	
}	
httpGet(url,	function(res)	{	
		if	(typeof	callback	===	'undefined')	{	
				value	=	res;	
		}	else	{	
				callback(res);	
		}	
});	
var	value,	callback;
- Return a function that
accepts a callback which will
provide the value, sometime
in the future.
- Run the async function when
created
- Wrap around a callback and
a future value
var	thunk	=	httpGetThunk(url);	
thunk(function(result)	{	
		//	here	we	have	the	result	
});	
How do we use it?

Recommended for you

Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...

Unlock the full potential of mobile monitoring with ONEMONITAR. Our advanced and discreet app offers a comprehensive suite of features, including hidden call recording, real-time GPS tracking, message monitoring, and much more. Perfect for parents, employers, and anyone needing a reliable solution, ONEMONITAR ensures you stay informed and in control. Explore the key features of ONEMONITAR and see why it’s the trusted choice for Android device monitoring. Share this infographic to spread the word about the ultimate mobile spy app!

hidden mobile spy appmobile spy app for parentsmobile spy app for android
Splunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptxSplunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptx

Splunk Presentation

COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...

Hironori Washizaki, "Charting a Course for Equity: Strategies for Overcoming Challenges and Promoting Inclusion in the Metaverse", IEEE COMPSAC 2024 D&I Panel, 2024.

One of:
1. Cache the callback
and call it with a value later
2. Cache the value and
pass it into a callback later
function	httpGetThunk(url)	{	
		var	value,	callback;	
			
		httpGet(url,	function(res)	{	
				if	(typeof	callback	===	'undefined')	{	
						value	=	res;	
				}	else	{	
						callback(res);	
				}	
		});	
		return	function(cb)	{	
				if	(typeof	value	===	'undefined')	{	
						callback	=	cb;	
				}	else	{	
						cb(value);	
				}	
		}	
}	
callback	=	cb;
callback(res);
cb(value);
value	=	res;
function	httpGetThunk(url)	{	
		var	value,	callback;	
			
		httpGet(url,	function(res)	{	
				if	(typeof	callback	===	'undefined')	{	
						value	=	res;	
				}	else	{	
						callback(res);	
				}	
		});	
		return	function(cb)	{	
				if	(typeof	value	===	'undefined')	{	
						callback	=	cb;	
				}	else	{	
						cb(value);	
				}	
		}	
}	
callback	=	cb;
callback(res);
We call the function
returned from the thunk
before the httpGet finishes
Option 1
1. Cache the callback
2. httpGet responds and
we call the cached callback
function	httpGetThunk(url)	{	
		var	value,	callback;	
			
		httpGet(url,	function(res)	{	
				if	(typeof	callback	===	'undefined')	{	
						value	=	res;	
				}	else	{	
						callback(res);	
				}	
		});	
		return	function(cb)	{	
				if	(typeof	value	===	'undefined')	{	
						callback	=	cb;	
				}	else	{	
						cb(value);	
				}	
		}	
}	
value	=	res;
cb(value);
We receive the value from
httpGet	before the
callback is called
Option 2
1. Cache the value
2. Our returned function is
called and we call the callback
That means we can write async code and pretend
that we already have the value
Whenever the value arrives is irrelevant!

Recommended for you

Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.

Shivam Pandit Php Web Dveloper

phpmysqlsql
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.
CViewSurvey Digitech Pvt Ltd that  works on a proven C.A.A.G. model.CViewSurvey Digitech Pvt Ltd that  works on a proven C.A.A.G. model.
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.

CViewSurvey is a SaaS-based Web & Mobile application that provides digital transformation to traditional paper surveys and feedback for customer & employee experience, field & market research that helps you evaluate your customer's as well as employee's loyalty. With our unique C.A.A.G. Collect, Analysis, Act & Grow approach; business & industry’s can create customized surveys on web, publish on app to collect unlimited response & review AI backed real-time data analytics on mobile & tablets anytime, anywhere. Data collected when offline is securely stored in the device, which syncs to the cloud server when connected to any network.

saasapplicationdigital marketing
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website

Lots of bloggers are using Google AdSense now. It’s getting really popular. With AdSense, bloggers can make money by showing ads on their websites. Read this important article written by the experienced designers of the best website designing company in Delhi –

website designing company in d
Let’s say we want to request value1 and value2 at the
same time but process them in order (value1 then value2)
//	parallel	requests	
var	thunk1	=	httpGetThunk(url1);	
var	thunk2	=	httpGetThunk(url2);	
//	processing	values	in	order	
thunk1(function(value1)	{	
		processValue(value1);	
		thunk2(function(value2)	{	
				processValue(value2);	
		});	
});	
function	httpGetThunk(url)	{	
		var	value,	callback;	
			
		httpGet(url,	function(res)	{	
				if	(typeof	callback	===	'undefined')	{	
						value	=	res;	
				}	else	{	
						callback(res);	
				}	
		});	
		return	function(cb)	{	
				if	(typeof	value	===	'undefined')	{	
						callback	=	cb;	
				}	else	{	
						cb(value);	
				}	
		}	
}
Thunks
Don’t mix input with output
Easier to sequentially reason about
Unreliable Execution
Don’t handle errors
Maintain state internally
//	parallel	requests	
var	thunk1	=	httpGetThunk(url1);	
var	thunk2	=	httpGetThunk(url2);	
//	processing	values	in	order	
thunk1(function(value1)	{	
		processValue(value1);	
		thunk2(function(value2)	{	
				processValue(value2);	
		});	
});
…but that code is complex, and usually has to be repeated for each
callback
If only we had a built in way to handle all of this….
Ok so, if we wanted to, we could solve most if not all callback
problems with a bunch of extra code

Recommended for you

dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf

dachnug51 | HCL Sametime 12 as a Software Appliance | Erik Schwalb

dnugdachnugdachnug51
dachnug51 - All you ever wanted to know about domino licensing.pdf
dachnug51 - All you ever wanted to know about domino licensing.pdfdachnug51 - All you ever wanted to know about domino licensing.pdf
dachnug51 - All you ever wanted to know about domino licensing.pdf

dachnug51 | All you ever wanted to know about domino licensing | Uffe Sorensen

dachnugdachnug51dnug
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdfResponsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf

What do fleet managers do? What are their duties, responsibilities, and challenges? And what makes a fleet manager effective and successful? This blog answers all these questions.

fleet managersresponsibilities of fleet mana
Non-Sequential Flow Unreliable Execution
Promises
Solutions?
Promises
Eventual result of an asynchronous operation
Wrappers around future values
Inherently Reliable
Eliminate time as a concern
}Like thunks
(but better)
- We can imagine as if we already have
the result, when it arrives is irrelevant.
Handle errors
Promises vs Callbacks Analogy
Promises
var	promise	=	new	Promise(function(resolve,	reject)	{	
	//	we	call	resolve()	on	success	
	//	we	call	reject()	on	fail	
});	
How do we create a Promise?
promise.then(function(value)	{	
		//	here	we	have	the	value	
},	function(error)	{		
		//	here	we	have	the	error	
});	
How do we use a Promise?

Recommended for you

ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf

Ansys Mechanical enables you to solve complex structural engineering problems and make better, faster design decisions. With the finite element analysis (FEA) solvers available in the suite, you can customize and automate solutions for your structural mechanics problems and parameterize them to analyze multiple design scenarios. Ansys Mechanical is a dynamic tool that has a complete range of analysis tools.

mechanical engineeringsoftware3d software
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdfIndependence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdf

Discover the rich history of US Independence Day 2024, tracing its origins and evolution as a national holiday, and its significance today.

us independence day 2024us independence dayindependence day 2024
NBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial CompanyNBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial Company

NBFC Software: Optimize Your Non-Banking Financial Company Enhance Your Financial Services with Comprehensive NBFC Software NBFC software provides a complete solution for non-banking financial companies, streamlining banking and accounting functions to reduce operational costs. Our software is designed to meet the diverse needs of NBFCs, including investment banks, insurance companies, and hedge funds. Key Features of NBFC Software: Centralized Database: Facilitates inter-branch collaboration and smooth operations with a unified platform. Automation: Simplifies loan lifecycle management and account maintenance, ensuring efficient delivery of financial services. Customization: Highly customizable to fit specific business needs, offering flexibility in managing various loan types such as home loans, mortgage loans, personal loans, and more. Security: Ensures safe and secure handling of financial transactions and sensitive data. User-Friendly Interface: Designed to be intuitive and easy to use, reducing the learning curve for employees. Cost-Effective: Reduces the need for additional manpower by automating tasks, making it a budget-friendly solution. Benefits of NBFC Software: Go Paperless: Transition to a fully digital operation, eliminating offline work. Transparency: Enables managers and executives to monitor various points of the banking process easily. Defaulter Tracking: Helps track loan defaulters, maintaining a healthy loan management system. Increased Accessibility: Cutting-edge technology increases the accessibility and usability of NBFC operations. Request a Demo Now!

nbfc softwarenbfc software solutionsnbfc software company
Promises
var	listener	=	new	Promise(function(resolve,	reject)	{	
	//	we	call	resolve()	on	success	
	//	we	call	reject()	on	fail	
});	
We can imagine Promise returning a listener
listener.on('success',	function(value)	{	
		//	here	we	have	the	value	
});	
listener.on('error',	function(error)	{		
		//	here	we	have	the	error	
});
Promises
var	promise	=	new	Promise(function(resolve,	reject)	{	
	//	we	call	resolve()	on	success	
	//	we	call	reject()	on	fail	
});	
promise.then(function(value)	{	
		//	here	we	have	the	value	
},	function(error)	{		
		//	here	we	have	the	error	
});	
- Creating a Promise returns immediately
- And we can use that promise anytime and anywhere later to
resolve it to a value
Do not mix input and output
Ok but how do Promises solve the problem of
Unreliability?
Developing Async Sense

Recommended for you

Promises are Reliable
Promise are inherently guaranteed to be resolvable once to a
single value, success OR error
Once resolved to a value, they become immutable
- their state cannot be changed
- they always resolve to that same value
var	promise	=	new	Promise(function(resolve,	reject)	{	
		resolve(1);	//	resolve	once	
		resolve(2);	//	resolve	second	time	(this	is	ignored)	
		reject(3);		//	this	is	also	ignored	
});

promise.then(function(result)	{	
		console.log(result);	//	1	
});

promise.then(function(result)	{	
		console.log('still	'	+	result);	//	still	1	
});	
Resolve once
Resolve to the same value
var	promise	=	new	Promise(function(resolve,	reject)	{	
		resolve({	greet:	'MiamiJS'	});	
});

promise.then(function(result)	{	
		console.log(result.greet);	//	MiamiJS	
		result.greet	=	'Oops';	
});

promise.then(function(result)	{	
		console.log(result.greet);	//	Oops	
});
Promises don’t get rid of callbacks.
They wrap callbacks in a reliable mechanism

Recommended for you

resolve(res);
reject(err);
});
new	Promise(function(resolve,	reject)	{	
function	httpGetPromise(url)	{	
		return	new	Promise(function(resolve,	reject)	{	
				httpGet(url,	function(err,	res)	{	
						if	(err)	{	
								reject(err);	
						}	else	{	
								resolve(res);	
						}	
				});	
		});	
}	
How do we convert a callback utility to Promises?
1. Wrap the utility in a Promise constructor
2. Call resolve on success and reject on error
processValues(values[0],	values[1]);
results.then
var	results	=	Promise.all([promise1,	promise2]);
var	promise2	=	httpGetPromise(url2);
var	promise1	=	httpGetPromise(url1);	
var	promise2	=	httpGetPromise(url2);	
var	results	=	Promise.all([promise1,	promise2]);	
results.then(function(values)	{	
		processValues(values[0],	values[1]);	
});	
var	promise1	=	httpGetPromise(url1);
Promises - Getting two values in parallel
Create promise2
and fire a request
Create promise1
and fire a request
var	promise1	=	httpGetPromise(url1);	
var	promise2	=	httpGetPromise(url2);	
var	results	=	Promise.all([promise1,	promise2]);	
results.then(function(values)	{	
		processValues(values[0],	values[1]);	
});	
Maintain state internally
Doesn’t mix input and output
DRY
Sequential Flow
Promises - Getting two values in parallel
Promises - Getting values in parallel (generalized)
var	promises	=	urls.map(function(url)	{	
			return	httpGetPromise(url);	
});	
var	results	=	Promise.all(promises);	
results.then(function(values)	{	
		processValues.apply(this,	values);	
});	
Maintain state internally
Doesn’t mix input and output
DRY
Sequential Flow

Recommended for you

Promise.all(

		urls.map(httpGetPromise)

).then(function(values)	{	
		processValues.apply(this,	values);	
});	
Promises - Getting values in parallel (generalized)
Promise.all(	
		urls.map(httpGetPromise)	
).then(	
		values	=>	processValues(...values)	
);	
Promises - Getting values in parallel (generalized & ES6)
Promises are chainable
We can respond to promises in a desired
order, regardless of when they actually
resolve
- Every then call returns a Promise
Sequential Flow
- Returning a Promise from then will append it to the promise chain
- Returning a non-thenable value from then will make it the next
resolved value in the chain and proceed down the chain.
Vertical Code -> Solves “Callback Hell”
return	promise2;
processValue(value2);
						function(value2)	{	
		
}
processValue(value1);
						function(value1)	{	
}
//	logging	value1	then	value2,		
//	regardless	of	which	value	is

//	received	first	
promise1	
.then(function(value1)	{	
		processValue(value1);	
})	
.then(function()	{	
		return	promise2;	
})	
.then(function(value2)	{	
		processValue(value2);	
});	
						function()	{	
}
Getting two values in parallel, process them in order
//	concurrent	("parallel")	requests	
let	promise1	=	httpGetPromise(url1);	
let	promise2	=	httpGetPromise(url2);	 value1 received first
1. receive value1
2. process value1
5. receive value2
6. process value2
3. proceed down the chain
4. Wait on promise2

Recommended for you

return	promise2;
processValue(value2);
						function(value2)	{	
		
}
processValue(value1);
						function(value1)	{	
}
//	logging	value1	then	value2,		
//	regardless	of	which	value	is

//	received	first	
promise1	
.then(function(value1)	{	
		processValue(value1);	
})	
.then(function()	{	
		return	promise2;	
})	
.then(function(value2)	{	
		processValue(value2);	
});	
						function()	{	
}
Getting two values in parallel, process them in order
//	concurrent	("parallel")	requests	
let	promise1	=	httpGetPromise(url1);	
let	promise2	=	httpGetPromise(url2);	 value2 received first
1. receive value2
2. receive value1
5. Wait on promise2
6. process value2
3. process value1
4. proceed down the chain
Promises can be chained into consistent Sequential Execution
Flow, no matter the order of their internal asynchronous
operations
We choose in which order to process results,
no matter when they arrive
Requesting values in parallel but processing them in
order
urls	
		.map(httpGetPromise)	
		.reduce(function(chain,	promise)	{	
				return	chain	
						.then(function()	{	
								return	promise;	
						})	
						.then(processValue);	
				},	Promise.resolve());	
		});	 Maintain state internally
Doesn’t mix input and output
DRY
Sequential Flow

Recommended for you

Error Handling
Errors thrown from promises are handled by the second parameter
(reject) passed to then or by the handler passed to catch
Errors thrown from promises skip all resolve handlers until a reject
handler or catch
A promise enters the rejection state when we manually call the reject
function or when a JS exception happens
Error Handling
var	promise	=	new	Promise(function(resolve,	reject)	{	
		reject(Error('an	error'));	
});	
promise.then(function()	{	
		//	not	called	
},	function(err)	{	
		err;	//	'an	error'	
});	
promise.catch(function(err)	{	
		err;	//	'an	error'	
});
Error Handling
var	promise	=	new	Promise(function(resolve,	reject)	{	
		2.method();	
});	
promise.then(function()	{	
		//	not	called	
},	function(err)	{	
		err;	//	'Uncaught	SyntaxError:	Invalid	or	unexpected	token'	
});	
promise.catch(function(err)	{	
		err;	//	'Uncaught	SyntaxError:	Invalid	or	unexpected	token'	
});
Error Handling
var	promise	=	new	Promise(function(resolve,	reject)	{	
		2.method();	
});	
promise.then(function()	{	
		//	not	called	
},	function(err)	{	
		err;	//	'Uncaught	SyntaxError:	Invalid	or	unexpected	token'	
})

.catch(function(err)	{	
	//	Doesn’t	get	called	because	it	was	handled	above	
});

Recommended for you

.catch(function(err)	{	
});	
===
.then(_,	function(err)	{	
});
Error Handling
function	getJSON(url,	cb)	{	
		httpGet(url,	function(err,	res)	{	
				if	(err)	return	cb(err);	
				try	{	
						res	=	JSON.parse(res);	
				}	catch(err)	{	
						return	cb(err);	
				}	
				cb(null,	res);		
		});	
}	
function	getJSON(url)	{	
		return	httpGetPromise(url)	
		.then(JSON.parse);	
}
urls	
		.map(httpGetPromise)	
		.reduce(function(chain,	promise)	{	
				return	chain	
						.then(function()	{	
								return	promise;	
						})	
						.then(processValue)	
						.catch(function(err)	{	
								//	err	is	the	error	from	the	current	promise	
						});	
				},	Promise.resolve());	
		});	
Error Handling
Ok, Promises are pretty good. Can we do better?

Recommended for you

Generators
Pausable functions
- A special type of function that can start and
stop execution one or more times and even
never finish
Break the Run-to-Completion Semantic
When combined with Promises they further improve
the Sequential Flow of async code
Generators
Generators are functions which can be exited and later re-entered.
Their context will be saved across re-entrances.
We can push out multiple values from them
Generators
function*	gen()	{	
		yield	'pause	here';	
		return	'I	am	done';	
}	
Calling the generator function returns an iterator.
var	iter	=	gen();	
Calling .next() on an iterator returns an object
with a value and a done flag
iter.next();	//	{	value:	any,	done:	boolean	}
Generators
yield	is a the pause/resume point of a generator
Calling .next()	on the iterator provided by the generator,
runs the code within the generator from the current paused
point (yield or start of the function) to the next pause point
(yield or end of the function)
Anything passed into .next()	gets pushed into the
generator as the return value from yield
Anything passed into yield	gets pulled from the generator
as the return value from iterator’s .next()

Recommended for you

yield
Push/Pull mechanism
function*	gen(s)	{	
		console.log(s);	
		console.log('yield	1	-	'	+		(yield	'A'));	
		console.log('yield	2	-	'	+		(yield	'B'));	
		console.log('end');	
		return	'C';	
}	
var	iter	=	gen(0);	
console.log(iter.next('a'));	
console.log(iter.next('b'));	
console.log(iter.next('c'));	
console.log(iter.next('d'));	
Console
{	value:	'A',	done:	false	}
'yield	1	-	b'
{	value:	'B',	done:	false	}
'yield	2	-	c'
'end'
{	value:	'C',	done:	true	}
{	value:	undefined,	done:	true	}
0
console.log('yield	1	-	'	+											);
console.log('yield	2	-	'	+											);
function*	gen(	)	{	
		console.log(	);	
		console.log('yield	1	-	'	+											);	
		console.log('yield	2	-	'	+											);	
		console.log('end');	
		return	'C';	
}	
var	iter	=	gen(0);	
'c'
'b'(yield	'A')
console.log(iter.next('c'));	
console.log(iter.next('b'));	
var	iter	=	gen(0);
console.log({	value:	'A',	done:	false	});console.log({	value:	'A',	done:	false	});console.log(iter.next('a'));	
console.log({	value:	'C',	done:	true		});console.log({	value:	undefined,	done:	true	});
console.log({	value:	'C',	done:	true		});console.log({	value:	'C',	done:	true		});
console.log({	value:	'B',	done:	false	});console.log({	value:	'B',	done:	false	});
iter.next('d')
return	'C';
console.log('end');
iter.next('c')
(yield	'B')
(yield	'A')
iter.next('b')
iter.next('a')
console.log(	);
0s
s0
(yield	'B')
¦¦ Pause
¦¦ Pause
console.log(iter.next('d'));	
Console
{	value:	'A',	done:	false	}
0
'yield	1	-	b'
{	value:	'B',	done:	false	}
'yield	2	-	c'
'end'
{	value:	'C',	done:	true	}
{	value:	undefined,	done:	
true	}
Ok but how does that help with Async code?

Recommended for you

Well…
What if a generator pushes out a Promise….
since generators pause and push on yield and wait for a pull so
they can continue….
and then continues running when the Promise resolves?
Promises + Generators => Control Flow Utopia
Synchronous looking Async Code
Chained requests with Generators
function	*httpGetGen(urls)	{	
		for	(var	i	=	0;	i	<	urls.length;	i++)	{	
				processValue(yield	httpGetPromise(urls[i]));	
		}	
}
Wait… what?

Recommended for you

runner(httpGetGen(['google.com',	'yahoo.com']));
processValue(																													);processValue(																													);
runner(iter,	value);
promise.then
function	runner(iter,	prev)	{	
		let	promise	=	iter.next(prev).value;	
		if	(promise)	{	
				promise.then(function(value)	{	
						runner(iter,	value);	
				});	
		}	
}	
runner(httpGetGen(['google.com',	'yahoo.com']));	
yield	httpGetPromise(urls[i])
iter.next(prev)
runner(iter,	value);
promise.then
yield	httpGetPromise(urls[i])
iter.next(prev)
Create promise1
and fire a request
to google.com
Create promise2
and fire a request 

to yahoo.com
iter.next(prev)
function	*httpGetGen(urls)	{	
		for	(var	i	=	0;	i	<	urls.length;	i++)	{	
				processValue(yield	httpGetPromise(urls[i]));	
		}	
}
function	*httpGetGen(urls)	{	
		for	(var	i	=	0;	i	<	urls.length;	i++)	{	
				processValue(yield	httpGetPromise(urls[i]));	
		}	
}	
Maintain state internally
Doesn’t mix input and output
DRY
Sequential &
Synchronous Flow
Chained requests with Generators
var	iter	=	httpGetGen('google.com',	'yahoo.com');var	iter	=	httpGetGen('google.com',	'yahoo.com');	
var	results	=	iter.next().value;	
results.then(function(values)	{	
		iter.next(values);	
});	
processValues(values[0],	values[1]);
values yield	Promise.all([promise1,	promise2]);
var	promise2	=	httpGetPromise(url2);
var	promise1	=	httpGetPromise(url1);
function	*httpGetGen(url1,	url2)	{	
		var	promise1	=	httpGetPromise(url1);	
		var	promise2	=	httpGetPromise(url2);	
		
		var	values	=	yield	Promise.all([promise1,	promise2]);	
							
		processValues(values[0],	values[1]);	
}	
iter.next(values);
results
results.then
iter.next()
Create promise1
and fire a request
to google.com
Create promise2
and fire a request to
yahoo.com
Generators - Getting two values in parallel
yield	Promise.all([promise1,	promise2]);
Generators - Getting two values in parallel
function	*httpGetGen(url1,	url2)	{	
		var	promise1	=	httpGetPromise(url1);	
		var	promise2	=	httpGetPromise(url2);	
		
		var	values	=	yield	Promise.all([promise1,	promise2]);	
							
		processValues(values[0],	values[1]);	
}	
Maintain state internally
Doesn’t mix input and output
DRY
Sequential &
Synchronous Flow
Only pauses
code within the
generator

Recommended for you

Synchronous splitting of “now” and ”later”
Generators - Getting values in parallel (generalized)
function	*httpGetGen(urls)	{	
		var	promises	=	urls.map(function(url)	{	
					return	httpGetPromise(url);	
		});	
		var	values	=	yield	Promise.all(promises);	
		processValues.apply(this,	values);	
}	
Maintain state internally
Doesn’t mix input and output
DRY
Sequential &
Synchronous Flow
Generators - Getting values in parallel (generalized & ES6)
function	*httpGetGen(url)	{	
		const	values	=	yield	Promise.all(urls.map(httpGetPromise));	
		processValues.apply(this,	values);	
}	
Maintain state internally
Doesn’t mix input and output
DRY
Sequential &
Synchronous Flow
What about requesting in parallel but processing in
order?

Recommended for you

Getting two values in parallel, process them in order
function	*httpGetGen(url1,	url2)	{	
		var	promise1	=	httpGetPromise(url1);	
		var	promise2	=	httpGetPromise(url2);	
		
		processValue(yield	promise1);	
		processValue(yield	promise2);							
}	
Maintain state internally
Doesn’t mix input and output
DRY
Sequential &
Synchronous Flow
How would we generalize it?
function	*httpGetGen(urls)	{	
		var	promises	=	urls.map(httpGetPromise);	
			
		for	(var	i	=	0;	i	<	promises.length;	i++)	{	
				processValue(yield	promises[i]);	
		}	
}	
Maintain state internally
Doesn’t mix input and output
DRY
Sequential &
Synchronous Flow
Error Handling
Has all the benefits of error handling with Promises
Can use try/catch !!!

Recommended for you

function	*httpGetGen(urls)	{	
		var	promises	=	urls.map(httpGetPromise);	
			
		for	(var	i	=	0;	i	<	promises.length;	i++)	{	
				try	{	
						processValue(yield	promises[i]);	
				}	catch(e)	{	
						//	e	is	the	error	from	the	current	promise	
				}	
		}	
}	
Error Handling
Asynchronous error handling looks synchronous
Eliminate Asynchronicity itself
Generators + Promises
Sequential Flow
Reliable
Eliminate time as a concern
- We can imagine as if we already have
the result, when it arrives is irrelevant.
Generators + Promises
Eliminate asynchronicity as a concern
- We can imagine as if we are performing
operations synchronously
But…
We have to make our own method to combine Promises and Generators
- Many cases to handle
- Corrupts the elegancy of this approach

Recommended for you

function	run(generator)	{	
		return	function()	{	
				var	iter	=	generator.apply(this,	arguments);	
				function	handle(result)	{	
						return	Promise.resolve(result.value)	
								.then(function(res)	{	
										return	handle(iter.next(res));	
								},	function(err)	{	
										return	handle(iter.throw(err));	
								});	
				}	
		}	
		return	handle(iter.next());	
}
run(function	*httpGetGen(url1,	url2)	{	
		var	promise1	=	httpGetPromise(url1);	
		var	promise2	=	httpGetPromise(url2);	
		
		processValue(yield	promise1);	
		processValue(yield	promise2);							
});
Or use a library…
http://taskjs.org/
https://github.com/tj/co
https://github.com/kriskowal/q
https://github.com/petkaantonov/bluebird
https://github.com/getify/asynquence
if only we had a built in solution for this…

Recommended for you

Async/Await
Generators + Promises, except we replace * with async and
yield with await
Stage 3 Proposal
Async function always returns a Promise
Async function can await for any value, not just a Promise
Chained requests with Async/Await
async	function	httpGetAsync(urls)	{	
		for	(var	i	=	0;	i	<	urls.length;	i++)	{	
				processValue(await	httpGetPromise(urls[i]));	
		}	
}	
Maintain state internally
Doesn’t mix input and output
DRY
Sequential &
Synchronous Flow
Native
async	function	httpGetAsync(urls)	{	
		var	promises	=	urls.map(httpGetPromise);	
			
		for	(var	i	=	0;	i	<	promises.length;	i++)	{	
				processValue(await	promises[i]);	
		}	
}	
Parallel requests with Async/Await
Maintain state internally
Doesn’t mix input and output
DRY
Sequential &
Synchronous Flow
Chaining
Since async functions return a Promise
We can chain them like Promises
We can await for them

Recommended for you

async	function	httpGetAsync(urls)	{	
		var	promises	=	urls.map(httpGetPromise);	
		var	values	=	[];	
		for	(var	i	=	0;	i	<	promises.length;	i++)	{	
				values.push(await	promises[i]);	
		}	
}	
async	function	processValues(urls)	{	
		var	values	=	await	httpGetAsync(urls);	
		//	...	do	stuff	with	out	values	
}
Error Handling
async	function	httpGetAsync()	{	
		var	promises	=	urls.map(httpGetPromise);	
			
		for	(var	i	=	0;	i	<	promises.length;	i++)	{	
				try	{	
						processValue(await	promises[i]);	
				}	catch(e)	{	
						//	e	is	the	error	from	the	current	promise	
				}	
		}	
}
Error Handling
httpGetAsync().catch(function(err)	{	
		//	...	
});
Sequential Flow
Reliability
Eliminate time as a concern
- We can imagine as if we already have
the result, when it arrives is irrelevant.
Eliminate asynchronicity as a concern
- We can imagine as if we are performing
operations synchronously

Recommended for you

Additional resources
https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/
What the heck is the Even Loop (https://www.youtube.com/watch?v=8aGhZQkoFbQ)
https://blog.risingstack.com/writing-a-javascript-framework-execution-timing-beyond-
settimeout/
https://github.com/getify/You-Dont-Know-JS
http://www.html5rocks.com/en/tutorials/es6/promises/
Promise Visualizer (http://bevacqua.github.io/promisees/)
https://ponyfoo.com/articles/understanding-javascript-async-await
Thank You
twitter.com/nem035

More Related Content

What's hot

All you need to know about the JavaScript event loop
All you need to know about the JavaScript event loopAll you need to know about the JavaScript event loop
All you need to know about the JavaScript event loop
Saša Tatar
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
stefanmayer13
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
Alexander Mostovenko
 
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
Allen Wirfs-Brock
 
Maintainable JavaScript 2011
Maintainable JavaScript 2011Maintainable JavaScript 2011
Maintainable JavaScript 2011
Nicholas Zakas
 
Rxjs kyivjs 2015
Rxjs kyivjs 2015Rxjs kyivjs 2015
Rxjs kyivjs 2015
Alexander Mostovenko
 
Streams in Node.js
Streams in Node.jsStreams in Node.js
Streams in Node.js
Sebastian Springer
 
JavaScript Async for Effortless UX
JavaScript Async for Effortless UXJavaScript Async for Effortless UX
JavaScript Async for Effortless UX
재석 강
 
Deep Dive into Zone.JS
Deep Dive into Zone.JSDeep Dive into Zone.JS
Deep Dive into Zone.JS
Ilia Idakiev
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
DroidConTLV
 
Real-Time Web Apps & Symfony. What are your options?
Real-Time Web Apps & Symfony. What are your options?Real-Time Web Apps & Symfony. What are your options?
Real-Time Web Apps & Symfony. What are your options?
Phil Leggetter
 
Real world functional reactive programming
Real world functional reactive programmingReal world functional reactive programming
Real world functional reactive programming
Eric Polerecky
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in Depth
C4Media
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
Erik van Appeldoorn
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scale
Tom Croucher
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open web
pjcozzi
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
UniRx - Reactive Extensions for Unity(EN)
UniRx - Reactive Extensions for Unity(EN)UniRx - Reactive Extensions for Unity(EN)
UniRx - Reactive Extensions for Unity(EN)
Yoshifumi Kawai
 
Node.js 0.8 features
Node.js 0.8 featuresNode.js 0.8 features
Node.js 0.8 features
Nicholas McClay
 
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJava
Frank Lyaruu
 

What's hot (20)

All you need to know about the JavaScript event loop
All you need to know about the JavaScript event loopAll you need to know about the JavaScript event loop
All you need to know about the JavaScript event loop
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
 
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
 
Maintainable JavaScript 2011
Maintainable JavaScript 2011Maintainable JavaScript 2011
Maintainable JavaScript 2011
 
Rxjs kyivjs 2015
Rxjs kyivjs 2015Rxjs kyivjs 2015
Rxjs kyivjs 2015
 
Streams in Node.js
Streams in Node.jsStreams in Node.js
Streams in Node.js
 
JavaScript Async for Effortless UX
JavaScript Async for Effortless UXJavaScript Async for Effortless UX
JavaScript Async for Effortless UX
 
Deep Dive into Zone.JS
Deep Dive into Zone.JSDeep Dive into Zone.JS
Deep Dive into Zone.JS
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
Real-Time Web Apps & Symfony. What are your options?
Real-Time Web Apps & Symfony. What are your options?Real-Time Web Apps & Symfony. What are your options?
Real-Time Web Apps & Symfony. What are your options?
 
Real world functional reactive programming
Real world functional reactive programmingReal world functional reactive programming
Real world functional reactive programming
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in Depth
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scale
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open web
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
UniRx - Reactive Extensions for Unity(EN)
UniRx - Reactive Extensions for Unity(EN)UniRx - Reactive Extensions for Unity(EN)
UniRx - Reactive Extensions for Unity(EN)
 
Node.js 0.8 features
Node.js 0.8 featuresNode.js 0.8 features
Node.js 0.8 features
 
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJava
 

Similar to Developing Async Sense

Asynchronous development in JavaScript
Asynchronous development  in JavaScriptAsynchronous development  in JavaScript
Asynchronous development in JavaScript
Amitai Barnea
 
Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScript
jnewmanux
 
Event Loop in Javascript
Event Loop in JavascriptEvent Loop in Javascript
Event Loop in Javascript
DiptiGandhi4
 
An opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathonAn opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathon
Luciano Mammino
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
Ankara JUG
 
A More Flash Like Web?
A More Flash Like Web?A More Flash Like Web?
A More Flash Like Web?
Murat Can ALPAY
 
Playing With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsPlaying With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.js
Mike Hagedorn
 
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
GITS Indonesia
 
JavaScript Multithread or Single Thread.pptx
JavaScript Multithread or Single Thread.pptxJavaScript Multithread or Single Thread.pptx
JavaScript Multithread or Single Thread.pptx
RAHITNATH
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
Ivano Malavolta
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
The evolution of java script asynchronous calls
The evolution of java script asynchronous callsThe evolution of java script asynchronous calls
The evolution of java script asynchronous calls
Huy Hoàng Phạm
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
NodeXperts
 
Responsive interfaces
Responsive interfacesResponsive interfaces
Responsive interfaces
Nicholas Zakas
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
Aarti Parikh
 
JavaScript Engines and Event Loop
JavaScript Engines and Event Loop JavaScript Engines and Event Loop
JavaScript Engines and Event Loop
Tapan B.K.
 
Node js lecture
Node js lectureNode js lecture
Node js lecture
Darryl Sherman
 
Performance patterns
Performance patternsPerformance patterns
Performance patterns
Stoyan Stefanov
 
JavaScript
JavaScriptJavaScript
JavaScript
Ivano Malavolta
 
Kotlin Coroutines and Rx
Kotlin Coroutines and RxKotlin Coroutines and Rx
Kotlin Coroutines and Rx
Shaul Rosenzwieg
 

Similar to Developing Async Sense (20)

Asynchronous development in JavaScript
Asynchronous development  in JavaScriptAsynchronous development  in JavaScript
Asynchronous development in JavaScript
 
Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScript
 
Event Loop in Javascript
Event Loop in JavascriptEvent Loop in Javascript
Event Loop in Javascript
 
An opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathonAn opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathon
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
 
A More Flash Like Web?
A More Flash Like Web?A More Flash Like Web?
A More Flash Like Web?
 
Playing With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsPlaying With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.js
 
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
 
JavaScript Multithread or Single Thread.pptx
JavaScript Multithread or Single Thread.pptxJavaScript Multithread or Single Thread.pptx
JavaScript Multithread or Single Thread.pptx
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
The evolution of java script asynchronous calls
The evolution of java script asynchronous callsThe evolution of java script asynchronous calls
The evolution of java script asynchronous calls
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Responsive interfaces
Responsive interfacesResponsive interfaces
Responsive interfaces
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
 
JavaScript Engines and Event Loop
JavaScript Engines and Event Loop JavaScript Engines and Event Loop
JavaScript Engines and Event Loop
 
Node js lecture
Node js lectureNode js lecture
Node js lecture
 
Performance patterns
Performance patternsPerformance patterns
Performance patterns
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Kotlin Coroutines and Rx
Kotlin Coroutines and RxKotlin Coroutines and Rx
Kotlin Coroutines and Rx
 

Recently uploaded

Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Sparity1
 
MVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptxMVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptx
Mitchell Marsh
 
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
Roshan Dwivedi
 
Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …
908dutch
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
MaisnamLuwangPibarel
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Estuary Flow
 
Folding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a seriesFolding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a series
Philip Schwarz
 
Attendance Tracking From Paper To Digital
Attendance Tracking From Paper To DigitalAttendance Tracking From Paper To Digital
Attendance Tracking From Paper To Digital
Task Tracker
 
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
onemonitarsoftware
 
Splunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptxSplunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptx
sudsdeep
 
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
Hironori Washizaki
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
shivamt017
 
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.
CViewSurvey Digitech Pvt Ltd that  works on a proven C.A.A.G. model.CViewSurvey Digitech Pvt Ltd that  works on a proven C.A.A.G. model.
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.
bhatinidhi2001
 
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website
e-Definers Technology
 
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
DNUG e.V.
 
dachnug51 - All you ever wanted to know about domino licensing.pdf
dachnug51 - All you ever wanted to know about domino licensing.pdfdachnug51 - All you ever wanted to know about domino licensing.pdf
dachnug51 - All you ever wanted to know about domino licensing.pdf
DNUG e.V.
 
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdfResponsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Trackobit
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
sachin chaurasia
 
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdfIndependence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Livetecs LLC
 
NBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial CompanyNBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial Company
NBFC Softwares
 

Recently uploaded (20)

Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
 
MVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptxMVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptx
 
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
 
Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
 
Folding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a seriesFolding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a series
 
Attendance Tracking From Paper To Digital
Attendance Tracking From Paper To DigitalAttendance Tracking From Paper To Digital
Attendance Tracking From Paper To Digital
 
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
 
Splunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptxSplunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptx
 
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
 
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.
CViewSurvey Digitech Pvt Ltd that  works on a proven C.A.A.G. model.CViewSurvey Digitech Pvt Ltd that  works on a proven C.A.A.G. model.
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.
 
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website
 
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
 
dachnug51 - All you ever wanted to know about domino licensing.pdf
dachnug51 - All you ever wanted to know about domino licensing.pdfdachnug51 - All you ever wanted to know about domino licensing.pdf
dachnug51 - All you ever wanted to know about domino licensing.pdf
 
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdfResponsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
 
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdfIndependence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
 
NBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial CompanyNBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial Company
 

Developing Async Sense