[REF] observer: notify subscribers directly

This rev. moves the logic of batching the notifications of changes
occurring in the same microtask tick, from the observer, to the
listeners (the context, and the render function of components).
By doing so in render, we ensure that similar renderings are
batched in a single one, wherever they come from (state change,
store change, direct call...).
This commit is contained in:
Géry Debongnie
2019-11-14 14:09:42 +01:00
parent e5940b4b6b
commit 56087b95cd
8 changed files with 33 additions and 34 deletions
-4
View File
@@ -3400,10 +3400,6 @@ describe("async rendering", () => {
});
test("change state and call manually render: no unnecessary rendering", async () => {
// when the state is changed, the component isn't notified directly (we wait
// for a microtask tick before calling 'render'), so it may happen that
// another rendering is done meanwhile, already using the new value of the
// state
class Widget extends Component<any, any> {
static template = xml`<div><t t-esc="state.val"/></div>`;
state = useState({ val: 1 });