Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What do TypeScript and Electron have in common ...

What do TypeScript and Electron have in common with air quality?

Air pollution is a concern of everybody since it may cause discomfort and adverse health effects. Children, elderly and those who have heart or lung problems suffer the most when the air around them is polluted. Polluted air can also adversely affect our quality of life.

This presentation is a case study of a side-project, a macOS menubar application that displays current CAQI level from the nearest Airly sensor station. Encountered problems, solutions, lessons learned.

Jakub Synowiec

January 24, 2018
Tweet

More Decks by Jakub Synowiec

Other Decks in Technology

Transcript

  1. Jakub Synowiec core engineer @ portent.io @jakubsynowiec @jsynowiec meet.js Katowice

    #29, 24.01.2018 What do TypeScript and Electron have in common with air quality?
  2. motivation • trail & obstacle course running, • healthy lifestyle

    and air quality awareness, • learn some new technologies, • there are many mobile apps, but.... ....they're mobile apps
  3. expectations I need a app for macOS, that: • runs

    in background, • periodically checks for current air quality measurements, • displays some normalized value of air quality on menubar, • looks and behaves like a native app, • shows system notification when air quality changes, I don't want to invest 2 weeks to learn Swift or ObjectiveC and tooling.
  4. decisions, technology • Electron, • Photon, Less, BEM, • React,

    • TypeScript, • Prettier, • API that provides near realtime, quality data,
  5. airqmon A macOS menu bar app that displays live air

    quality measurements from the nearest Airly sensor station. It also notifies you when the air quality changes or when a new station that is closer to your current location was found. https://github.com/jsynowiec/airqmon
  6. Packaging with electron-packager missing production packages • electron-packager runs
 `npm

    prune !--production`
 when packaging, • due to a bug, npm removes all production dependencies installed from git, i.a. git, git+http(s), git+ssh, github/reponame • app crashes :( https://github.com/npm/npm/issues/19356
  7. Airly API data stability Data hide & seek: • pressure,

    humidity temperature are sometimes missing, • sometimes there is no data at all, GIOŚ stations don't return current measurement data: • need to find latest among historical measurements,
  8. conclusions • Electron is nice but has some quirks to

    learn, • React is easier with TypeScript, • React and BEM styles play well together, • Preact is even better than React, • You can't test all possible scenarios by yourself, some "field" tests are necessary, • npm@5 has serious problems in terms of maintenance, • Created three issues and a PR in different projects, • Prettier won't replace a linter but it helps a lot, • It never ends on PoC state, • It's better to get a mask or wait till spring,