Bitcoin price tracker built with React, Redux, and Webpack, inspired by Preev. Uses Redux Thunk, ES7 async/await, and fetch to get exchange data, then calculates a weighted average and updates once every 10 seconds (updates the title tag too!).
- React view layer
- Redux state management
- Redux Thunk for async action creators
- Redux Actions for creating Flux Standard Actions
- React Helmet to update the title tag
- Immutable.js
- Github's fetch polyfill for older browsers
- Babel w/ stage-3 preset for async/await
- CSS Modules so we can import and inline CSS
- PostCSS with Autoprefixer and PreCSS
- Webpack for module bundling
fetch
returns a promise, so we can await
the completion of a request in an async
function!
(async () => {
// fetch data
const response = await fetch('https://apiv2.bitcoinaverage.com/constants/exchangerates/global');
// read response to json format
const json = await response.json();
// the API gives us the number of Bitcoins in 1 USD, but we want
// the number of USD in 1 BTC, so we can use the ES7 exponentiation operator
return json.rates.BTC.rate ** -1;
})();
- Search for '@todo' in the code
- Making the text flash on updates would be nice
- Add stocks and other things to exchange! (AAPL etc)
- Use redux-actions
handleAction
in reducers - Use
redux-form
for form handling - Consolidate action files (getting data and form actions could be two categories)
- Add an eslint config and more tests
- Wrap switch statements in blocks and make sure they break or return
- Better code coverage (write tests/cover fetch() fail)