Gathering detailed insights and metrics for mobx-form-store
Gathering detailed insights and metrics for mobx-form-store
Gathering detailed insights and metrics for mobx-form-store
Gathering detailed insights and metrics for mobx-form-store
npm install mobx-form-store
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
10 Stars
88 Commits
4 Forks
1 Watchers
8 Branches
1 Contributors
Updated on May 01, 2025
Latest Version
3.0.0
Package Id
mobx-form-store@3.0.0
Unpacked Size
50.41 kB
Size
13.26 kB
File Count
4
NPM Version
6.14.11
Node Version
14.15.5
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
2
20
FormStore is part of a collection of loosely-coupled components for managing, rendering and validating forms in MobX-based apps.
https://alexhisen.gitbooks.io/mobx-forms/
Instances of FormStore (models) store the data entered by the user into form fields and provide observables for managing validation error messages. They also track changes and provide facilities for (auto-)saving the (changed) data.
Previously, server.create() was called (instead of server.set()) only when the property defined as the idProperty in store.data was falsy. This worked well if the idProperty was only returned by the server and was not user-enterable. Now whether server.create() is called is driven by a new store.status.mustCreate property which is true only when the idProperty has not yet been returned by the server / saved even if it already has a value in store.data. Note that MobxSchemaForm v.1.14+ supports a readOnlyCondition property that can be set to "!model.status.mustCreate" to allow an id property to be entered but not modified.
FormStore only requires MobX 2.2+, 3.x, 4.x or 5.x. MobX strict mode is currently not supported. FormStore does not implement the actual server requests, it only calls methods that you provide with the data to be sent to the server.
npm install --save mobx-form-store
myStore.js (a Singleton):
1import FormStore from 'mobx-form-store'; 2 3const model = new FormStore({ 4 server: { 5 // Example uses ES5 with https://github.com/github/fetch API and Promises 6 get: function() { 7 return fetch('myServerRefreshUrl').then(function(result) { return result.json() }); 8 }, 9 10 // Example uses ES6, fetch and async await 11 set: async (info) => { 12 const result = await fetch('myServerSaveUrl', { 13 method: 'POST', 14 headers: { 15 Accept: 'application/json', 16 'Content-Type': 'application/json', 17 }, 18 body: JSON.stringify(info), 19 }); 20 return await result.json() || {}; // MUST return an object 21 } 22 }, 23}); 24 25export default model;
IMPORTANT: Your server.get method MUST return an object with ALL properties that need to be rendered in the form. If the model does not yet exist on the server, each property should have a null value but it must exist in the object or it cannot be observed with MobX.
myForm.jsx (this is without MobxSchemaForm (with it there is even less code)).
1import React from 'react'; 2import { observer } from 'mobx-react'; 3import model from './myStore.js' 4 5@observer class MyForm extends React.Component { 6 componentDidMount() { 7 model.refresh(); 8 } 9 10 onChange = (e) => { 11 model.data[e.target.name] = e.target.value; 12 model.dataErrors[e.target.name] = myCustomValidationPassed ? null : "error message"; 13 } 14 15 onSaveClick = () => { 16 if (!model.status.canSave || !model.status.hasChanges) return; 17 if (myCustomValidationPassed) model.save(); 18 } 19 20 render() { 21 return ( 22 {/* ... more fields / labels ... */} 23 24 <label className={model.dataErrors.myProperty ? 'error' : ''}>My Property</label> 25 <input 26 type="text" 27 name="myProperty" 28 className={model.dataErrors.myProperty ? 'error' : ''} 29 value={model.data.myProperty || ''} 30 readonly={model.status.isReadOnly} 31 onChange={this.onChange} 32 /> 33 <p>{model.dataErrors.myProperty}</p> 34 35 <button 36 className={(!model.status.canSave || !model.status.hasChanges) ? 'gray' : ''} 37 onClick={this.onSaveClick} 38 > 39 Save 40 </button> 41 ); 42 } 43}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
32 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
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