antenna.io

Antenna is a small studio crafting websites and web apps.

Function currying in Javascript

What is function currying? The concept sounds a bit mysterious and perhaps the best explanation I could find comes from the Pro TypeScipt book: Currying is a process whereby a function with multiple parameters is decomposed into multiple functions that each take a single parameter.

Link

Stub lifecycyle hooks in Vue

It's quite a common pattern to initialise a component in a created() or mounted() hook. The problem is that these hooks will execute every time a component is mounted as part of the tests and it may not be what you want.

Link

Preload and replay sounds in Expo

Expo comes with an Audio API that provides basic sound playback and recording capabilities in React Native projects. It includes a lot of useful features, but at times can be tricky to work with because of its asynchronous nature. I collected a few bits of information that can help with setting up and playing audio in Expo. 🎛️

Link

Mock asynchronous API calls in Vue component tests

This post collects a few notes on how to mock asynchronous API calls when testing Vue components.

Link
Cover image

Create portals to render content in another part of the DOM, instead of inside the Vue component

Portals provide a way to render content into a DOM node that exists outside the hierarchy of the Vue component that creates the portal. The concept of portals also exists in React. When the need arises I rely on the portal-vue library to create portals, which provides a really clean syntax.

Link

Keep your sanity and use JSON Schema to validate nested JSON documents

Let's take a hypothetical JSON object that holds various pieces of data and describes a request for currency conversion. Then let's explore how JSON Schema can help with the validation of its structure.

Link

Handle single and double clicks on the same element in Vue.js

I was looking for a way to handle single click and double click events on the same element in Vue.js. At first it looked like 'v-on:dblclick' is going to cover this requirement nicely, but I soon discovered it's not ideal. While double clicking the 'click' event fires too (as soon as the first click of an intended double click is registered), which makes it hard to handle both types of events at the same time.

Link

Modify array keys in PHP

I'm interested in functional programming lately and was happy to discover that modifying array keys in PHP can be done avoiding any kind of loops. 😃

Link