Skip to content

Instantly share code, notes, and snippets.

View ascoders's full-sized avatar
🎯
Focusing

黄子毅 ascoders

🎯
Focusing
View GitHub Profile
@ascoders
ascoders / index.html
Created June 16, 2017 14:28
dynamic-object-react-demo // source https://jsbin.com/wesafur
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>dynamic-object-react-demo</title>
<script src="https://fb.me/react-0.14.0.min.js"></script>
<script src="https://fb.me/react-dom-0.14.0.min.js"></script>
<script src="https://unpkg.com/dynamic-object@2.1.15/built/bundle.js"></script>
</head>
<body>
| Mobx | Dob |
|---|----|
| autorun | **observe** |
| observable | observable |
| unobservable | unobservable |
| reaction | reaction |
| computed | `Not needed` |
| extendObservable | `Not needed` |
| arrays | `native array` |
| maps | `native Map & Set` |
| Mobx | Dob |
|---- |---- |
| autorun | **observe** |
| observable | observable |
| unobservable | unobservable |
| reaction | reaction |
| computed | `Not needed` |
| extendObservable | `Not needed` |
| arrays | `native array` |
| maps | `native Map & Set` |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
| Mobx | Dob |
|---- |---- |
| autorun | **observe** |
| observable | observable |
| unobservable | unobservable |
| reaction | reaction |
| computed | `Not needed` |
| extendObservable | `Not needed` |
| arrays | `native array` |
| maps | `native Map & Set` |
Mobx **Dob**
autorun observe
observable observable
unobservable unobservable
reaction reaction
computed `Not needed`
extendObservable `Not needed`
arrays `native array`
maps `native Map & Set`

A proxy version of mobx: dob

Why use proxy to achieve mobx? Because mobx is very good, but because of Object.defineProperty restrictions, no way to write very comfortable.

So dob was born, I only list the changes after using dob, as well as the experience of store manager framework practice summary.

1 Introduction

dob not only overrides mobx using proxy, but also comes with dependency injection store management.

Mobx Dob
autorun observe
observable observable
unobservable unobservable
reaction reaction
computed Not needed
extendObservable Not needed
arrays native array
maps native Map & Set