Gathering detailed insights and metrics for mobx-state-tree
Gathering detailed insights and metrics for mobx-state-tree
Gathering detailed insights and metrics for mobx-state-tree
Gathering detailed insights and metrics for mobx-state-tree
Full-featured reactive state management without the boilerplate
npm install mobx-state-tree
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
6,988 Stars
2,341 Commits
641 Forks
90 Watching
31 Branches
234 Contributors
Updated on 28 Nov 2024
Minified
Minified + Gzipped
TypeScript (98.34%)
JavaScript (1.55%)
HTML (0.05%)
CSS (0.04%)
Dockerfile (0.02%)
Shell (0.01%)
Cumulative downloads
Total Downloads
Last day
-6.4%
18,503
Compared to previous day
Last week
-1%
98,879
Compared to previous week
Last month
3.9%
413,055
Compared to previous month
Last year
-0.6%
4,408,034
Compared to previous year
1
27
Technically speaking, mobx-state-tree (also known as MST) is a state container system built on MobX, a functional reactive state library.
This may not mean much to you, and that’s okay. I’ll explain it like this: MobX is a state management "engine", and MobX-State-Tree gives it structure and common tools you need for your app. MST is valuable in a large team but also useful in smaller applications when you expect your code to scale rapidly. And if we compare it to Redux, MST offers better performance and much less boilerplate code than Redux!
MobX is one of the most popular Redux alternatives and is used (along with MobX-State-Tree) by companies worldwide. MST plays very well with TypeScript, React, and React Native, especially when paired with mobx-react-lite. It supports multiple stores, async actions and side effects, enables extremely targeted re-renders for React apps, and much more -- all in a package with zero dependencies other than MobX itself.
Note: you don't need to know how to use MobX in order to use MST.
See the Getting started tutorial or follow the free egghead.io course.
👉 Official docs can be found at http://mobx-state-tree.js.org/
There's nothing quite like looking at some code to get a feel for a library. Check out this small example of an author and list of tweets by that author.
1import { types } from "mobx-state-tree" // alternatively: import { t } from "mobx-state-tree" 2 3// Define a couple models 4const Author = types.model({ 5 id: types.identifier, 6 firstName: types.string, 7 lastName: types.string 8}) 9const Tweet = types.model({ 10 id: types.identifier, 11 author: types.reference(Author), // stores just the `id` reference! 12 body: types.string, 13 timestamp: types.number 14}) 15 16// Define a store just like a model 17const RootStore = types.model({ 18 authors: types.array(Author), 19 tweets: types.array(Tweet) 20}) 21 22// Instantiate a couple model instances 23const jamon = Author.create({ 24 id: "jamon", 25 firstName: "Jamon", 26 lastName: "Holmgren" 27}) 28 29const tweet = Tweet.create({ 30 id: "1", 31 author: jamon.id, // just the ID needed here 32 body: "Hello world!", 33 timestamp: Date.now() 34}) 35 36// Now instantiate the store! 37const rootStore = RootStore.create({ 38 authors: [jamon], 39 tweets: [tweet] 40}) 41 42// Ready to use in a React component, if that's your target. 43import { observer } from "mobx-react-lite" 44const MyComponent = observer((props) => { 45 return <div>Hello, {rootStore.authors[0].firstName}!</div> 46}) 47 48// Note: since this component is "observed", any changes to rootStore.authors[0].firstName 49// will result in a re-render! If you're not using React, you can also "listen" to changes 50// using `onSnapshot`: https://mobx-state-tree.js.org/concepts/snapshots
No vulnerabilities found.
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
2 commit(s) and 9 issue activity found in the last 90 days -- score normalized to 9
Reason
Found 18/30 approved changesets -- score normalized to 6
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More