Git Product home page Git Product logo

chaostheory's Introduction

Production Url

https://chaos-theory.netlify.app

Design and Implementation

Driver

The application is driven by function fetchExchangeRate defined in ./src/index.tsx, which has the following properties:

  • it fetches the exchange rates regularly and update the state reactively,
  • it is called every INTERVAL_FOR_FETCHING_RATES_SEC (imported from ./src/settings.ts, which defaults to 60s) seconds,

Layout

Two main parts: Header and Body

  • Header: An app header bar for hosting links to different pages,
  • Body: A component for hosing all pages. If new pages need to be added, tweak ./src/components/Routes.tsx.

State Management

Considering this project is quite small, instead of using a state management library, Observer Patten is implemented to make the application reactive to state updates.

  • The fetched exchange rateSet are stored in the state of ./src/misc/state.ts,
  • The only way to update the state is to call relevant update function defined in ./src/misc/state.ts, which will do two things:
    • update the state
    • notify the listeners
  • To listen to the state change, simply call the custom hook useObserver wherever in your component with a listener function passed in as an argument. When the state updates, the listener will be called,
  • When updating the state, try to replace the old state with a new state, so that the setState function derived from useState can always work.

Settings

Some settings could be adjusted at ./src/settings.ts

Getting Started

This project was bootstrapped with Create React App.

How to run

In the project directory, you can run:

yarn install for installing the dependies

yarn start for starting the project locally

How to test

yarn test --watchAll

How to build

yarn build

How to prettify

npx prettier --write **.ts **.tsx

Reference

chaostheory's People

Contributors

tristanwyl avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.