Von Michael Hansen, (Kommentare: 0)

JavaScript Promises - how to (not) use it

How do you handle asynchronous operations in JavaScript? Working with callback function was the common way for years and it still feels like spending some time with a good old friend. But using callback functions do have some drawbacks (we will talk about later). Since ES2015 we have Promises. ES2017 will even simplify the work with asynchronous operations. So, if you didn't take a deeper look into Promises yet, you should. Promises can be a real game changer for your code - if you use them right.

Weiterlesen …

Von Merle Ehm, (Kommentare: 0)

Better AJAX API

Do you still make AJAX request this way (jQuery style)?

$.ajax({ 
   type: "GET", 
   url: "/some/url", 
   success: function(response) { 
     console.log(response);
   } 
});

Or do you even use the odd XMLHttpRequest object like this?

Weiterlesen …

Von Merle Ehm, (Kommentare: 0)

The best way to unit test React components using ES6 with Babel

Some days ago a colleague asked me how to write tests for React components. It wasn't just a challenge to write the tests but also to set up the whole environment to run the tests and measuring the code coverage. I did some googling to solve the problem and I realised that there are several ways to solve them. Some solutions work and some not. I will show you my solution that works!

Weiterlesen …

Von Jan Hansen, (Kommentare: 0)

React – What and why?

Countless posts have been done about react so here goes another one. :) React is a framework for developing web applications by Facebook. BUT unlike Angular or Ember.js or others it features ONLY the view layer. This cannot be stressed enough when talking about which framework to use for a new project. React does not offer an MVC pattern or similar things. There is no data layer, no connection libraries to the backend, no wrapper functions to ajax calls, no promises and so on. React does however feature some interesting view layer features and architecture ideas.

Weiterlesen …