Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/dobPublic

Light and fast 🚀 state management tool using proxy.

License

NotificationsYou must be signed in to change notification settings

dobjs/dob

Repository files navigation

dob

Dob is a tool for monitoring object changes. UsingProxy.

Online Docs.

Examples

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.

Use in react

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'))

Useinject to pick stores in action, do notnew UserStore(), it's terrible for later maintenance.

Project Examples

Ecosystem

  • 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.

Note

Dependency injection does not support circular references

Do not allow circular dependencies between store and action, It's impossible to do like this:

classA{    @inject(B)b}classB{    @inject(A)a}

Do not deconstruct to the last level on dynamic object

constobj=observable({a:1})// goodobj.a=5// badlet{ a}=obja=5

Inspired

About

Light and fast 🚀 state management tool using proxy.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp