. .

react-router in Twitter and Pinterest style

On the documentation website for react-router, there’s an example titles Modal Gallery (code given here). It was called the Pinterest style in previous versions: v2 and v3.

IMO, the versions 2.x and 3.x were more obvious and clear in their approach. It was tough alone to grasp the logic involved in the v4 approach - especially the use of multiple !foo and !!bar expressions. Trying to add the Twitter style in it melted my brain.

So I tried some other way, which works too.

Read more

Async in sync

For a concurrent language like JS, developers have to deal with a lot of asynchronous workflow. One of the hardest things to accomplish with asynchronous code is to make it run in serial order (serial, as in, the opposite of parallel).

The default way to go is using callbacks, even if it sometimes leads to the callback hell.

  foo(function(fooResp) {
    console.log(fooResp);

    bar(fooResp, function(barResp) {
      console.log(barResp);

      buzz(someVar, function(buzzResp, err) {
        // handle response and error
      });
    },

    function(err) {
      // handle error
    });
  });

As the language evolves, we get newer syntax and techniques to deal with this problem.

Read more

Ye Olde Generators

Generators are one of the features that were added to the language’s core in recent times. And people really like generators (though not more than the spread operator).

But just like the new class, generators aren’t something that didn’t exist before. Sure, the syntax didn’t, but even in the ye olde days of ES3, writing generators was possible.

Read more

2017 Thus Far

New Year, New Me and a bunch of whole new irritations.

Read more

Browser history functioning and loopback gotcha

According to MDN,

The History interface allows to manipulate the browser session history, that is the pages visited in the tab or frame that the current page is loaded in.

But how exactly does the browser keep track of the visited pages?

Read more