Telegraph with RxJS

Alexander Inkin
AngularWave

--

I was watching a movie the other day. There was a guy using telegraph. He had to remember the whole Morse code by heart and press his single button crazy fast! It got me thinking. With RxJS we can do better! Let’s make a telegraph using single fromEvent and lots of cool stuff. We will practice Dependency Injection, other Angular features, and awesome RxJS usage to build a working demo that looks (and sounds) great. Here we go!

Morse code

Telegraph uses Morse code. It’s pretty easy for us to understand as it is just a binary sequence. The signal is discrete, meaning it is broken into segments of a particular duration. At every given piece it’s either a “bleep” or silence. We can use Boolean or just 1s and 0s for brevity. It follows the rules below:

  • There are two symbols: dash and dot
  • Dash is three 1s in a row
  • Dot is a single 1
  • They are separated by a single 0
  • Letters are separated by three 0s
  • Words are separated by seven 0s (we can see this as space being four 0s + three 0s of char end)

Each letter is represented by the sequence depicted in the table below. You can also see the signal grid, black square means 1, white square is 0.

--

--

Alexander Inkin
AngularWave

Passionate Angular dev, musician and OSS author 🌲 taiga-ui.dev ··· 🎹 jamigo.app