Legend-state: High performance state and local first sync
legendapp.com·18h·
Discuss: Hacker News

⚡️ Fine-grained reactivity in React

Achieve incredible performance by minimizing the number and size of renders. Legend State makes apps fast by default because they just do less work.

🦄 Incredibly easy to use

When you get() values while observing, it tracks them and re-runs when they change. No boilerplate, no selectors, no dependency arrays, just easy reactivity.

const settings$ = observable({ ui: { theme: 'dark' }})

// Infinitely nested observables
const theme$ = settings$.ui.theme

// get returns the raw data
theme$.get() // 'dark'

// set sets
theme$.set('light')

// Computed observables with just a function
const isDark$ = observable(() =>
theme$.get() === 'dark'
)

// observe re-runs when observables change
observe(() => {
console.log(theme$.get())
})

// use$ r...

Similar Posts

Loading similar posts...