We love reading, watching, and listening in order to keep our skills sharp and our perspectives fresh. Here are some of the resources we learned from this month.
An Introduction to Ractors in Ruby
đ¨ Experimental feature alert! đ¨Ractors were introduced in Ruby 3 and represent an actor-model abstraction. Ractors provide true-blue parallelism and do not have thread-safety concerns. Intrigued? So are we. This article will allow you to get your feet wet with Ractors in Ruby and understand what they are, why they are useful, and how to implement one of your own.
TurboReady
Canât get enough of the Hotwire ecosystem? Same. The Rails community has really rallied around the suite of tools that includes Turbo, Stimulus, and Strada (yet to be released). Since it came on the scene in 2021, there have been an increasing amount of projects that seek to augment its functionality. See TurboReady, which extends Turbo Streams to allow full control of the browserâs DOM. This will allow you to write code like this: turbo_stream.invoke "console.log", args: ["Hello World!"]
. Pretty neat, huh? Just be sure to pay special attention to âA word of cautionâ in the README. đ
.in_order_of
A new addition in Rails 7. This method is a nifty shorthand for writing queries that need to order the records in a non-standard way. Now you can simply write Category.in_order_of(:id, [3, 1, 2])
and Rails will translate it into âCASE⌠WHENâ, which will make the result match the order passed in the array. One caveat: this method will also limit the records to those that match one of the values passed, in our example categories with other IDs will not be returned, even though upon inspection the raw SQL does include an else
(at least in Postgres). That was done so that the method matches its Enumerable counterpart. I think a version of this method without this constraint would also be a welcome addition.
React Error Boundaries: A Complete Guide
The dreaded âwhite screenâ scenario. Youâve seen it, Iâve seen it, but the good news is - we donât have to see it so long as we take care to handle errors and exceptions gracefully. One way to accomplish this in our React apps is to leverage Error Boundaries, which are plain olâ class React components that implement the componentDidCatch(error)
function. This article will walk you through how to implement Error Boundaries in your app, cover some limitations, and introduce libraries that can help in advanced contexts.
The Orton Effect - dreamy photo effect in CSS and React
In the age of social media, images with filters applied are a dime a dozen. But have you ever attempted to create your own using The Orton Effect? The Orton Effect is a technique in photography that involves taking an in-focus image and an out-of-focus image and layering them on top of one another to create a âdreamyâ visual effect. This article walks you through how to implement this technique using CSS and React.
Official Congress API
No PATCH
or POST
requests? We thought this was a democracy!? Oh well. We still think itâs pretty neat that there is an official API that allows the public to ingest Congressional data. There are a handful of resources available including but not limited to bills
, amendments
, members
, and treaties
.