This is a demo to show how offline app can be made simply with JsStore.
In Chat Room Demo, The messages sent or received are stored locally in indexedDB using JsStore and synced with the server in each request.
If the user is offline or server is not responding, the messages are stored locally and these failed messages are pushed to server and new messages are fetched from the server whenever user goes online or server starts responding.
Two new things are introduced in this demo which you should know:
-
JsStore: It is an IndexedDB Wrapper. It makes IndexedDB super easy with its SQL like apis.
-
Json-server: It provides API for CRUD operation on any json file(say db.json) which contains the data(like a Database) It run on node.js.
If node.js is not installed in your system then you can get it from here.
Open the Node.js command prompt and go to the directory(ChatRoomDemo) which contains package.json
file
then enter the command below
$ npm install
This command will install the required modules for this demo.
Open the Node.js command prompt and go to the directory(ChatRoomDemo) which contains the db.json
file. Once you are pointing to the ChatRoomDemo directory in Node.js command prompt, enter the command below
$ npm start
The site will be hosted at http://localhost:8080.
Now you can start playing with this demo by going offline and online from the Network
tab of Browser Developer tool