Issue #24

Anthonny Quérouil is continuing his coverage of using Elm and Meteor, this time on how to use Meteor packages to add support for user accounts. Inside you will find explanation on creating a web component and using that in Elm, on using subscriptions and ports. Pretty much all the necessary topics to get you an idea of what Elm is and how it works and interacts with JavaScript.

For a more comprehensive example of how to create a web component, Wolfgang Schuster created fluent-web in order to use Fluent for localization which was mentioned in #13.

Learning about Elm made me borrow some concepts into other languages. Elm also opened the world of functional programming to me. I knew some bits of it from Python too but never relied on it heavily. Elm changed that too. I recently stumbled upon fxapp/fxapp, a library to help you build JavaScript server apps using effects as data. If you go through the explanation post by Wolf David Wedemeyer, he refers a lot to the way Elm influenced core design decisions. The article contains a lot of other references worth your time.

Videos

Bugs can't hide: A full stack exploration in type safety

Packages

I must say that until recently I didn't know the term "debouncing function". I did intuitively implement them on few occasions, but I never knew the theory, which would have saved me from many embarrassing moments.

Assume you have a search form with auto-complete functionality. Every time a user types a character you want to present them with preliminary results. But if the user types a long sentence you don't want to send a request for each character typed only to dismiss the results because several more characters have been typed already while the code was waiting for response. As such, you want to have some graceful period of time until the input is considered "stable" enough to warrant an action. This is where debouncing comes into play: you specify the wait time after which your function fires. Do not confuse it with the throttling function which is guaranteed to fire at certain intervals of time.

There are quite a lot of packages for Elm already. I liked the simplicity of grotsev/elm-debouncer. The code is very easy to understand: every time there is an event (e.g. user typing), a counter is incremented and we delay a function which then gets executed after a timeout and checks if the counter is zero. If it is, it runs our code, if not, the counter is decremented. This is obviously a very simplified package, and if you need something more complicated, e.g. cancel the execution of the delay function midway, take a look at another package.

If you're into 3D, Ian Mackenzie has just published version 1.0.0 of his 3D rendering engine for Elm. Here is the announcement. I suggest you also browse his public repos on Github as there are several amazing packages, one of which is ianmackenzie/elm-geometry. The documentation, examples, and the code are a joy to look at.

Quote of the week

It took less than an hour to make the atoms, a few hundred million years  to make the stars and planets, but five billion years to make man!

By George Gamow from "The Creation of the Universe"

Show Comments