JavaScript Promises Essentials

Book Cover

I have some very exciting news!

My book titled JavaScript Promises Essentials has been published. For the past couple of months I was a bit :) busy with authoring this small technical book of around 90 pages. It was a great challenge, as the topic is very focused. This book is my second publication after the title Developing Windows Store Apps with Html5 and JavaScript which was published last year around the same time. My second authoring experience and it is getting better, I do hope that I will be able to find time in the future for more books and maintain the rhythm. The book was published by Packt Publishing whose team of editors, technical editors, reviewers and project managers provided me with a great guidance and support throughout the authoring period. Moreover, I would like to thank Brian Cavalier for his support and taking the time to contribute with his knowledge on the topic.

The book has the following details:

  • ISBN: 139781783985647
  • Paperback: 90 pages

In a nutshell, the main topic of the book is JavaScript Promises; which is a new programming concept in JavaScript that allow developers to request data that they don’t have yet and deal with it at a non-determined point in the future (asynchronously). Starting with the basics of the promise objects, we’ll be able to leverage the maximum capabilities of promises when writing applications.

The book starts by giving you some background information on the asynchronous programming model in JavaScript, recognizing its importance in JavaScript programming. It then walks you through the key concepts and intricacies of the Promises API. Following that, you will learn how you can write complex asynchronous operations with chained promises and be able to catch and handle exceptions. This book aims at providing you with the essential knowledge needed to write better asynchronous operations using JavaScript promises

Who This Book Is For

If you are a JavaScript developer working with asynchronous operations and want to know more about promises, then this book is ideal for you. Having a detailed explanation of JavaScript promises will be perfect as your next step towards adopting this new standard and using the API in your web and JavaScript applications.

Here is a list of some of the things that you will learn from reading this book:

  • Implement asynchronous programming in JavaScript
  • Get acquainted with the JavaScript Promises API
  • Choose the right JavaScript libraries to use callbacks in a non-compatible platform
  • Write chained asynchronous operations that are easy to manage
  • Master WinJS Promises for developing Windows applications
  • Differentiate between various implementations of promises in JavaScript
  • Put promises into action in your applications
  • Catch and handle errors effectively in asynchronous operations
  • Explore browser support and platform compatibility for JavaScript promises

Read more about the book on this link, or download a sample chapter from here

You can also find the book on Amazon available in Paperback  and Kindle Edition via this link:

Happy Reading :)

Posted in Books Tagged with: ,

The simplest JavaScript Promises examples

You might have heard the new buzz word Promises. I am not going to take long explaining Promises in this post, I will have another just on that topic. But for now, what you need to know is the following

  • Promise/A+ is the open standard for sound, interoperable JavaScript promises.
  • “Promise” in the A+ spec is defined as “an object or function with a then method whose behavior conforms to this specification”.
  • Promises present a great solution to address the complexities of asynchronous operations in JavaScript.
  • Promises are native with ECMAScript 6
  • Promises save you from the “CallBack Hell”
  • Promises have been implemented in numerous JavaScript libraries and many of which are complaint to the Promises/A+ spec.
  • It is available in WinJS but it adheres to the CommonJS/Promises proposal and still is not complaint to the Promises/A+ spec

I wanted to share with you the simplest example of an asynchronous call with Promises. The following code can be viewed in this JSFiddle as well

var promTest = function () {
return new Promise(function (resolve) {
setTimeout(resolve, 2000);
promTest().then(function () {
alert("and then?");
}, function (error) {
alert("i have errored");

The previous code is straightforward, we created a variable called promTest and assign it to a function that returns a new promise, we create a new promise that is resolved with a setTimeout after 2 seconds.
Then we call that promise with its then() method and pass it alert() in the success handler and alert(“i have errored”!) in the error handler.
Run the code in an HTML page or the above JSFiddle link and you will see it action.

Now how about a simple example that uses an XMLHttpRequest to make a web call and retrieve a JSON content  using promises. You can test it on this JSFiddle:

<div id="result" style="color: red;"> </div>

var getJSON = function(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();'get', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
} else {
getJSON('').then(function(data) {
// alert('Your Json result is: ' + data.result); //you can comment this, i used it to debug
result.innerText = data.result; //display the result in an HTML element
}, function(error) { //error detection....
alert('Something went wrong.' + error);

The code is simple again, we define a function called getJSON that returns a promise, it makes an xhr call to a URL, this web call returns json retrieved in the result of the then() method after it succeeds, then we put that result in an div element for display. you can add/remove a letter from the URL to cause an error and see how it is alerted.

Posted in Web Development Tagged with:

Book Review: Building Web and Mobile ArcGIS Server Applications with JavaScript

Book Cover

Another book review of a book that I recently had the chance to go through.This publication was titled Building Web and Mobile ArcGIS Server Applications with JavaScript.

As the tagline states, this book really allows you to master the ArcGIS API for JavaScript. Reading this book leaves you equipped with the knowledge and tools to build some good web and mobile GIS applications with the ArcGIS Server. The ArcGIS space is a vast one in terms of implementation and this book does cater for the essentials topics needed.
The book is a must read for anyone interested in working with ArcGIS in the JavaScript world. The book presents several examples that allow the reader to reason about the usefulness of ArcGIS. The author leverages the visuals in a very good way that enhances the level of understanding for the readers.
The book contains a thorough description and details about the API and the classes it offers amplified with examples for using those classes.
One thing that caught my attention was the section about the comments in the code, which I personally think is a must when writing large chunks of code.
In general the book’s approach of step-by-step instructions and examples allows the reader to quickly learn and deeply understand the key features and design.
Nevertheless, I had mixed feelings regarding the first chapter Introduction to HTML, CSS and JavaScript. Well I skipped it and any developer would do. It is targeted for those who are very new to this topic. I would assume that people interested in this book would be knowledgeable in those concepts. Needless to say, the chapter is great for new comers to the HTML and JS world.
The cherry on top was the last chapter which covers support for mobile platforms provided by the ArcGIS Server API for JavaScript provides through the compact build.

It is a very good read, for anyone who is interested in learning about the topic.
Happy reading :)

Posted in Books Tagged with: , ,

Azure from Visionary to Leader in 1 Year

Gartner Report 2014 Vs. 2013

Gartner Report 2014 Vs. 2013

Microsoft Azure IaaS from a visionary to a leader in less than a year on Gartner.


Microsoft has announced the general availability of Azure Infrastructure Services a little over a year ago. And from that time, features and enhancements have been pouring over that cloud offering and at a very quick rate. Addressing customer and partner feedback with features that Azure users have been asking for.  Back then, specifically in August 2013,  Microsoft was named a visionary in the Infrastructure as a Service front in the Gartner Report.
Moving forward, in less than a year, all that hard work and efforts have paid off and this week  Gartner has named Microsoft as a Leader in its 2014 Cloud Infrastructure as a Service (IaaS) Magic Quadrant report.
This comes after a short after Gartner recognized Microsoft as a Leader in the Enterprise Application Platform as a Service (aPaaS) market in its 2014 Enterprise aPaaS Magic Quadrant.

This new announcement makes Microsoft the only public cloud vendor to be named a Leader for both PaaS and IaaS.

I am personal fan of Azure, so I thought I would share the good news.
You can check the full report here.
And remember cloud is the future.

Posted in Windows Azure Tagged with: , , ,

Book review of Windows Phone 8 Application Development Essentials

Book cover - Windows Phone 8 Application Development Essentials

Hello Folks!

This is no technical post, as you can clearly tell from the title, this is a review of a book that I recently had the chance to go through.
PACKT Publishing  “one of the most prolific and fast-growing tech book publishers in the world” and of course the publisher of my book Developing Windows Store Apps with HTML5 and JavaScript, recently contacted me with the ask of reviewing one of their new publications titled Windows Phone 8 Application Development Essentials,
and I accepted the ask with utmost delight.

Just having a look at the Table of Contents, makes you certain that you are on a very good read. I have an experience with Windows 8 app development with strong emphasis on Javascript/HTML5 and always wanted to learn the essentials of Windows Phone development with XAML. So if you share the same story, someone who wants to learn about Windows Phone development from A to Z, then you will find this book very helpful.

Chapter 1 brings a great introduction to XAML in Windows Phone, covering the most important topics for someone who wants to develop for Windows phone: common controls, containers, navigational controls and working with data.  The controls are very well documented.

Moving forward, you will learn about the design principles and best practices from a fellow Windows Phone developer.

Chapter 3 covers MVVM (The Model View ViewModel architectural pattern), the backbone of developing Windows Phone apps, and interestingly the chapter covers the aspects of the MVVM that you will need in Windows Phone development and doesn’t elaborate more, which is more than you need if you are there to learn about Windows Phone 8 development only.  A great thing about this chapter is that it covers the MVVM light toolkit that developers find a very useful and allows speed of development with Windows Phone.
Then the author, briefly covers the integration with the Windows Phone as a device with topics of launchers (camera launcher for example), notifications, storage, files and background agents.

Last chapter, is like the dessert following a very healthy meal, sweet but not too heavy. Teaching you in details, how to integrate with Facebook and Twitter APIs which will help you implement great features in an app. The author goes in details, step by step with each.

In a nutshell, it was an excellent read. Furthermore, the book is great for the developers who want a jump start course on Windows Phone 8 app development while learning about very important topics in programming which are XAML and MVVM pattern. This book will also be your guide along the way after you finish it, it will serve as a resourceful reference.

Happy Reading

Posted in Uncategorized Tagged with: , , ,