mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[DOC] improve the documentation
closes #340 closes #344 closes #352 closes #355
This commit is contained in:
+5
-7
@@ -38,14 +38,14 @@ const actions = {
|
||||
state.todos.push({
|
||||
id: state.nextId++,
|
||||
message,
|
||||
isCompleted: false,
|
||||
isCompleted: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const state = {
|
||||
todos: [],
|
||||
nextId: 1,
|
||||
nextId: 1
|
||||
};
|
||||
|
||||
const store = new owl.Store({ state, actions });
|
||||
@@ -113,6 +113,7 @@ const actions = {
|
||||
```
|
||||
|
||||
The first argument to an action method is an object with four keys:
|
||||
|
||||
- `state`: the current state of the store content,
|
||||
- `dispatch`: a function that can be used to dispatch other actions,
|
||||
- `getters`: an object containing all getters defined in the store,
|
||||
@@ -200,8 +201,7 @@ const post = store.getters.getPost(id);
|
||||
|
||||
Getters take _at most_ one argument.
|
||||
|
||||
Note that getters are cached if they don't take any argument, or their argument
|
||||
is a string or a number.
|
||||
Note that getters are not cached.
|
||||
|
||||
### Connecting a Component
|
||||
|
||||
@@ -212,7 +212,6 @@ can be done with the help of the three store hooks:
|
||||
- `useDispatch` to get a reference to a dispatch function,
|
||||
- `useGetters` to get a reference to the getters defined in the store.
|
||||
|
||||
|
||||
Assume we have this store:
|
||||
|
||||
```javascript
|
||||
@@ -223,7 +222,7 @@ const actions = {
|
||||
};
|
||||
|
||||
const state = {
|
||||
counter: {value: 0}
|
||||
counter: { value: 0 }
|
||||
};
|
||||
const store = new owl.Store({ state, actions });
|
||||
```
|
||||
@@ -256,7 +255,6 @@ two arguments:
|
||||
- optionally, an object with a `store` key (if we want to override the default
|
||||
store) and an equality function (if we want to specialize the comparison).
|
||||
|
||||
|
||||
If the `useStore` callback selects a sub part of the store state, the component
|
||||
will only be rerendered whenever this part of the state changes. Otherwise, it
|
||||
will perform a strict equality check and will update the component every time this
|
||||
|
||||
Reference in New Issue
Block a user