Skip to content

A repo demoing asynchronous functions and HTTP requests in JavaScript.

License

Notifications You must be signed in to change notification settings

jgome284/async-js

Repository files navigation

Asynchronous-ities with iJS! 😺

Logo

Foreword

Notebook detailing asynchronous functions in JavaScript and HTTP Requests.
Report Bug · Request Feature


Table of Contents

About

Often in web development, we need to handle asynchronous actions— actions we can wait on while moving on to other tasks. We make requests to networks, databases, or any number of similar operations. JavaScript is non-blocking: instead of stopping the execution of code while it waits, JavaScript uses an event-loop which allows it to efficiently execute other tasks while it awaits the completion of these asynchronous actions.

JavaScript is an interesting language; it's single threaded, but it's built to mimic multi-threaded-isities to free itself from blocking sequential code. It does so by pushing callbacks with promises for handling through a WebAPI. For a good introduction, checkout this article and the diagram below.

JavaScript Engine Diagram

This project provides a playground for asynchronous functions and HTTP requests in JavaScript. It includes a jupyter notebook with iJavaScript that provides several examples. iJavaScript is a Javascript kernel for the Jupyter notebook. The Jupyter notebook combines the creation of rich-text documents (including equations, graphs and videos) with the execution of code in a number of programming languages. The execution of code is carried out by means of a kernel that implements the Jupyter messaging protocol. The iJavaScript kernel executes Javascript code inside a Node.js session. And thus, it behaves as the Node.js REPL does, providing access to the Node.js standard library and to any installed npm modules.

Setup

This project is setup with a Dev Container for use on Visual Studio Code. It serves as a full-featured development environment with everything needed to run JavaScript on the jupyter notebook. Dev Containers separate tools, libraries, or runtimes needed for working with a codebase. They aid in continuous integration and testing. Dev containers can be run locally or remotely, in a private or public cloud, in a variety of supporting tools and editors.

This devcontainer, is built IAW the dev containers specification and tailored for a build environment that leverages Ubuntu. Of note, the devcontainer has git for version control and several extensions installed for Visual Studio Code as development utilities for the IDE.

Prerequisites

Docker

To start, you need to have Docker Engine and Docker Compose on your machine. You can either:

VSCode

This devcontainer is setup for development on Visual Studio Code. You should have it installed along with the remote development pack to enable the IDE's devcontainers functionality.

Getting Started

To start, open VS Code in a directory of your choice. Open the terminal and clone this repository with git clone https://github.com/jgome284/async-js.

Open Docker Desktop to run the Docker daemon, a background process that manages and coordinates Docker containers on your system. On VS Code, start the development container by running Dev Containers: Rebuild and Reopen In Container in the command palette. It can be accessed with the keyboard shortcut ctrl + shift + P on your keyboard.

If successful, Visual Studio will establish a remote connection to the development container. When it does, feel free to look over the examples on async-js.ipynb and create your own notebook to try working with JavaScript on your own!