React, etc. Tech Stack

Facebook's Relay and how it relates to Flux and React

The technical preview of Facebook's Relay was launched early this week. It is fully Open Source and available on Github today. But what exactly is Relay and how does it relate to React and Flux?

In 2013 Facebook released React, a JavaScript tool that helps developers create complex user interfaces with high performance dynamic updates and independent components. In 2014 Facebook released Flux, a tool to keep track of the state on client side. In 2015 they completed the trio with Relay, a library that handles communications with the persistent storage (i.e. a remote server).

Here is a rundown of the Facebook JavaScript Clientside development stack:

All of these different items have specific roles and each of them can be replaced. Flux, for example has multiple competing implementations, such as Redux. They are well decouped an in traditional Facebook development team tradition, Relay is already dogfooded and in production on Facebook.com.

The development team lists the following future focus areas and possibilities

Offline support. Relay is not tied to server communications, and updates can be queued for synching in offline state and synched once connected.

Real-time updates. The team is working together with the GraphQL community to stardardise on a specification for real time updates

A generic Relay. Just as React never forced any specific state implementation, the team is looking into synching state with servers, in-memory and native device APIs.

Support for patchy connectivity. Relay is designed to work with intermittent availability to network connections, queuing and handling situations with limited (or slow) network community. This is increasingly important in a world where mobile devices rule.