Demo link: https://hknews.herokuapp.com
npm install npm run start
Application structure:
- Main source folder “HKNews”
- Source code folder “src”
- Production build folder “build”
- Static resources folder “public”
- Application configuration “src/config.js”
- Dependency configuration “package.json”
- Home page parameter “package.json” => "homepage": http://localhost:3000
- “web.config” included for deploying to Internet Information Server with MVC routing Running the source:
- Unzip the file HKNews
- Open terminal in the root folder
- Run => “npm install”
- Run =>”npm run start”
- In the browser open => http://localhost:3000 Production deployment:
- Change "homepage": http://localhost:3000 => to the home page URL
- From a terminal in the root folder run => “npm run build”
- Copy the files from “build” folder to the production site Application features:
- Home page display top stories
- It automatically updates every 60 seconds
- Uses setTimeOut ( it could be done with service worker or socket.io but they may not be supported in some user browsers. With more time it can be coded to fall back to setTimeout if not supported but right now It just uses seTimeout ).
- After click on “comments” it navigates to the second page and shows all the comments for the selected post – collapsed.
- After click on plus sign – it will expand as set by the specification.
- It will update every 60 seconds.
Technologies:
- React JS with Redux JS
- Auto-Updating the page is done asynchronously
- I use “JQuery get” because the app already is using JQuery and I do not want to add other dependencies.
- The get request caches the response. If JQuery receives http response 304 – it will not reload the response
- Auto-Updating uses React feature to update only the part of the DOM where there is a change in the data.