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. …
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. …
UPDATE NOTE: Updated the Proxy Pattern example to use ES6 Proxy and Reflect. Replaced images of source code snippets with GitHub gists.
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.
Note: I will be using some ES6+ syntax including
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. …
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. …