Categories: NodeJS

Difference Between Promise and Observable Subscription

Jul 17, 2021 2 min.

Anyone who looks Promise and Observable at first it might looks like they both solve the same purpose i.e.they both used for asynchronous functionality, and immediately question arises what is the difference? which one is best? Which one I should use? Promise Promise is simple and strightforward to use compare to observable It is a better option when you want to do something asynchrously for one time Code looks cleaner with async/await Observable It is slightly complex to use compare with Promise however it is much more powerful than Promise It can be used for getting multiple responses i.

NodeJS - Unit Test DynamoDB

May 10, 2019 2 min.

Introduction This page explains how to mock dynamodb client using Sinon and Proxyqurie Required dependencies Install the following dependencies npm install --save-dev sinon npm install --save-dev proxyquire Sample Project Setup a sample project # Create a sample project directory mkdir myproject cd myproject # Initalize npm npm init -y # Install project dependencies npm install aws-sdk # Install Unit test framework globally (if you have not already installed) npm install -g mocha # Install Test dependencies npm install --save-dev sinon npm install --save-dev proxyquire create a index.