Skip to content

Commit

Permalink
Merge pull request #46 from Houfeng/v8
Browse files Browse the repository at this point in the history
mota@8.1.3
  • Loading branch information
Houfeng authored Jun 13, 2022
2 parents 8677b34 + 2ab7283 commit 76870e5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ const model = observable({ count: 0 });
const add = ()=>model.count++;

const View1 = observer(() {
return <div>{model.count}</div>
return <div>{model.count}</div>;
});

const View2 = observer(() {
return <div>
<span>{model.count}</span>
<button onClick={add}>click<button>
</div>
</div>;
});
```

Expand All @@ -53,7 +53,7 @@ const View = observer(() {
return <div>
<span>{model.count}</span>
<button onClick={()=>model.count++}>click<button>
</div>
</div>;
});
```

Expand All @@ -69,8 +69,10 @@ const user = observable({

const View = observer(() {
// The fullName will be cached and responsive
const fullName = useComputed(()=>`${user.firstName} ${user.lastName}`);
return <div>{fullName}</div>
const fullName = useComputed(()=>{
return `${user.firstName} ${user.lastName}`;
});
return <div>{fullName}</div>;
});
```

Expand All @@ -88,7 +90,7 @@ const View = observer(() {
useAutoRun(()=>{
console.log('count:', model.count);
});
return <div>{model.count}</div>
return <div>{model.count}</div>;
});
```

Expand All @@ -105,7 +107,7 @@ const View = observer(() {
useWatch(()=>model.count%10, (oldValue, newValue)=>{
console.log(`old: ${oldValue}, new: ${newValue}`);
});
return <div>{model.count}</div>
return <div>{model.count}</div>;
});
```

Expand Down Expand Up @@ -141,7 +143,7 @@ class View extends React.Component {
return <div>
<span>{this.message}</span>
<button onClick={this.add}>click<button>
</div>
</div>;
}
}
```
Expand All @@ -168,7 +170,7 @@ class View extends React.Component {
return <div>
<span>{this.model.message}</span>
<button onClick={()=>this.model.add()}>click<button>
</div>
</div>;
}
}
```
2 changes: 1 addition & 1 deletion examples/benchmark-mota.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useEffect } from 'react';

ObserveConfig.maxDependencies = Number.MAX_SAFE_INTEGER;
ObserveConfig.maxHandlers = Number.MAX_SAFE_INTEGER;

let renderCount = 0;

const markRender = () => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mota",
"version": "8.1.2",
"version": "8.1.3",
"description": "An extremely lightweight and responsive state management library",
"module": "./dist/mota-es.js",
"main": "./dist/mota-cjs.js",
Expand All @@ -21,7 +21,7 @@
},
"license": "MIT",
"dependencies": {
"ober": "8.2.6",
"ober": "8.2.8",
"tslib": "*"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
*/

export const name = "mota";
export const version = "8.1.2";
export const version = "8.1.3";
4 changes: 1 addition & 3 deletions src/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ function createReactiver(
bind = true
) {
const update = (info?: ObserveData) =>
isSyncRequired(info?.value)
? requestUpdate()
: nextTick(requestUpdate, true);
isSyncRequired(info?.value) ? requestUpdate() : nextTick(requestUpdate);
return reactivable(render, { bind, update, batch: false });
}

Expand Down

0 comments on commit 76870e5

Please sign in to comment.