- Notifications
You must be signed in to change notification settings - Fork35
Light and fast 🚀 state management tool using proxy.
License
NotificationsYou must be signed in to change notification settings
dobjs/dob
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Dob is a tool for monitoring object changes. UsingProxy.
There are somedemo on fiddle. Here's the simplest:
import{observable,observe}from"dob"constobj=observable({a:1})observe(()=>{console.log("obj.a has changed to",obj.a)})// <· obj.a has changed to 1obj.a=2// <· obj.a has changed to 2
You can enjoy the benefits of proxy, for exampleobj.a = { b: 5 } is effective.
import{Action,observable,combineStores,inject}from'dob'import{Provider,Connect}from'dob-react'@observableexportclassUserStore{name='bob'}exportclassUserAction{ @inject(UserStore)privateUserStore:UserStore; @ActionsetName(){this.store.name='lucy'}}@ConnectclassAppextendsReact.Component{render(){return(<spanonClick={this.props.UserAction.setName}>{this.props.UserStore.name}</span>)}}ReactDOM.render(<Provider{ ...combineStores({ UserStore, UserAction})}><App/></Provider>,document.getElementById('react-dom'))
Use
injectto pick stores in action, do notnew UserStore(), it's terrible for later maintenance.
- dob-react simple example
- dob-react hackernews
- dob-react todoMVC
- dob-react complex online web editor
- dob-redux todoMVC
- dob-react - Connect dob to react! Here is a basicdemo, and here is ademo with fractal.Quick start.
- dob-react-devtools - Devtools for dob-react, with action and ui two way binding.
- dob-redux - You can use both dob and Redux by using it! Enjoy the type and convenience of dob, and the ecology of Redux.
- dob-refect - Auto fetch, away from the trouble of
componentDidUpdate.
Do not allow circular dependencies between store and action, It's impossible to do like this:
classA{ @inject(B)b}classB{ @inject(A)a}
constobj=observable({a:1})// goodobj.a=5// badlet{ a}=obja=5
About
Light and fast 🚀 state management tool using proxy.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.