gitmyhub

dva

JavaScript ★ 16k updated 11mo ago

🌱 React and redux based, lightweight and elm-style framework. (Inspired by elm and choo)

Dva is a lightweight JavaScript front-end framework that wraps Redux and redux-saga with a small 6-API surface and Elm-style models bundling state, reducers, and effects.

JavaScriptReactReduxredux-sagasetup: easycomplexity 3/5

Dva is a lightweight JavaScript framework for building web application front-ends. It sits on top of Redux (a popular tool for managing app-wide data and state) and redux-saga (a library for handling things like API calls and other side effects), and wraps them in a simpler, more organized API. Instead of writing a lot of Redux boilerplate — the repetitive setup code that Redux normally requires — dva lets you define your app's logic in compact "models" that bundle together the state, the functions that update it, and side effects like data fetching.

The framework is inspired by Elm, a functional programming language with a strict data-flow architecture, and applies that pattern to JavaScript apps. Each model in dva has three parts: reducers (pure functions that update state), effects (async logic, like fetching data from a server), and subscriptions (listeners that react to events like URL changes). The idea is that instead of scattering these pieces across many files, you keep them together in one place per feature.

Dva claims to have only six core APIs to learn, making it quicker to pick up than raw Redux. It supports Hot Module Replacement, which means your browser automatically updates when you save a file during development without losing your app's current state. A plugin system allows optional add-ons, such as automatic loading state management. The README notes that over 1,000 projects use it at Alibaba. It is written in JavaScript and published as an open-source package.

Where it fits