Image for post
Image for post
Picture credits:

Atomicity and Transactions

Before we can discuss MongoDB transactions, we need to know a little bit about atomicity and how it relates to Database and MongoDB in particular. Anything is atomic in nature if it is an indivisible and irreducible series of database operations such that either all occur, or nothing occurs.

So in simple terms, what Transactions allow us to do is group multiple database operations in a way, that either all of them succeed or none of them do. Suppose, we have two users John and Jane. John transfers $10 to Jane’s account. …

Image for post
Image for post
Photo by Simon Abrams on Unsplash

In this article, we will create a simple reusable React component that tracks “Page Visibility State.”

When creating a web application you may come across situations where you need to track the current visibility state of the app. You may need to play/pause a video or animation effect, throttle some performance intensive work or simply track the user’s behaviour for analytics based on whether the browser tab is active or not.

Now, this feature seems pretty simple to implement until you actually try to implement it for the first time. …

The ultimate guide to the most useful design patterns

Image for post
Image for post

UPDATE NOTE: Updated the Proxy Pattern example to use ES6 Proxy and Reflect. Replaced images of source code snippets with GitHub gists.

In this article, we are going to talk about design patterns that can be and should be used to write better, maintainable JavaScript code. I assume you have a basic understanding of JavaScript and concepts like classes (classes in JavaScript can be tricky), objects, prototypal inheritance, closures, etc.

This article is a long read as a whole because of the nature of the subject matter, so I have tried to keep the sections self-contained. So you as a reader can pick and choose specific parts (or, in this case, specific patterns) and ignore the ones you are not interested in or are well versed with. …

Learn the basics of React by making a tiny app in minutes.

Image for post
Image for post

React is a very popular JavaScript library created by Facebook and used by many other industry leaders like Netflix, Airbnb, etc. It’s a library for building user interfaces. It introduces many new concepts about how to approach building complex user interfaces. We will explore the core concepts of how you can build apps with React. We will touch all the basics you need to know to start feeling comfortable using React.

Note: I will be using some ES6+ syntax including class, arrow functions,const, let, import, export, etc. I suggest you to go through Introduction to ES6 if you are not familiar with the new updated syntax. We will skip all the build tools setup, thanks to Codesandbox — It gives you a ready to go Development Environment right in your browser.

Image for post
Image for post
The welcoming image on Webpack’s homepage defines itself in the best way (i.e. without any jargons)

What is Webpack?

Well that’s simple — Webpack is a module bundler for JavaScript applications.

Now, to back it up a little bit let’s see how modules work in JavaScript. Modules, as in any other programming language, help you break down your code into smaller separate parts. This pattern helps in managing growing complexity by keeping concerns separate into their independent parts. Simply put, modules help organize code.

Before ES6, this could be done using different script files and then loading each of them separately with a <script> tag in our HTML. This had many disadvantages like fetching multiple files, maintaining the correct order of the script tags to avoid accidentally breaking any dependent code and many more. …


Soumyajit Pathak

Experimenting with code and words.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store