Minimal, powerful declarative VDOM and reactive programming library.
MIT License
Relax is a minimal, powerful declarative VDOM and reactive programming library.
This tiny 2.5KB (.min.gz) engine lets you define data-driven apps using declarative components. Relax combines ideas from Meteor, Mithril and Preact into one simple library. Relax supports:
render
<li key="key1">
) for efficient diffingshouldComponentUpdate
Relax gives you what you need to build not only simple todo apps, but also rapidly-updating apps like stock tickers.
Meteor.Tracker.autorun
in a few lines of code on top of Relax.render
called.Relax isn't a "framework", it's a small library that helps you avoid huge frameworks. Relax abstracts out the heavy lifting associated with common UI and state management tasks (reconciliation, efficient data flow propagation, reactive functions, etc.). Build your own framework: Many frameworks can be built in a few lines of code with Relax's primitives:
Relax's inner-diff (instance-level diff
) API is inspired by Mithril's redraw
. If you prefer React syntax, hooks and other React-like APIs can also be built pretty easily with Relax's primitives:
setState
setState
useEffect
useLayoutEffect
useState
useRef
afterAll
, after
, before
, beforeAll
, afterMount
, beforeUnmount
, afterUpdate
If you've ever tinkered with Meteor, you've probably been obsessed with Tracker.autorun
at some point. Nobody blames you -- it is awesome. If you wanted to, you could implement the exact same API using Relax nodes as Relax supports dependency graphs out-of-the-box. Relax makes it easy to implement reactive patterns such as:
Meteor.Tracker
Meteor.ReactiveVar
Meteor.ReactiveDict
Meteor.Collection
(reactive collection)Meteor.Collection.find
that supports sort, filter, and multiple listeners per querynpm install --save atlas-relax
You are assumed to be familiar with transpiling code (babel, webpack, etc.). In the future, I may make a dist/
folder containing various transpiled-minified code for quick installment.
Relax is an experimental library and your feedback is greatly appreciated! If Relax has piqued your interest 👀 then read the source code! I've included implementation comments for your reference. If you are curious how some things were implemented, check out the development history. There are a few things I want to implement in the future:
dist/
files
Meteor, Mithril, Preact and physics analogies. MIT License.
The gif above was made with the help of Paul Falstad's atomic dipole transition applet. Check out his other amazing interactive physics playgrounds over at his website: http://www.falstad.com/mathphysics.html.