-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] point_of_sale: lazy reactive getters
This commit introduces an implementation of lazy reactive computed value that is pull-based -- it only recomputes when it's needed. Check the following PR in odoo/owl for its origin: odoo/owl#1499 It's basically an automatic caching mechanism that taps to the reactivity primitive of odoo/owl. Because it depends on odoo/owl's reactivity, the logic inside a getter is only recomputed when its dependencies changed. Example: Given the following base values `A`, `B`, `C` and `D`, and dependent values `AB`, `BC` and `X`. ```mermaid graph TD A --> AB B --> AB B --> BC C --> BC AB --> X D --> X ``` - Changing `A` should recompute `AB` and `X`. - Changing `B` should recompute `AB`, `BC` and `X`. - Changing `C` should recompute `BC`. - Changing `D` should recompute `X`. It's also pull-based (thus called _lazy_) which means that recomputations are only called when necessary. Imagine a view (component) is only displaying `AB` and `BC` (check above diagram). Changing `D` should invalidate value of `X`, but since the view isn't dependent on `X`, there won't be a rerendering and the logic of `X` won't be called. An obvious benefit of this change is performance but we can consider it as minor. A case where performance change is noticeable is when pos loaded 20k products. In that situation, before this commit, there is a noticeable delay when clicking a product. With this commit, the app feels as if only few products are loaded. Aside from performance, developers also benefits on debugging getters because the logic is only called once per rendering. DX will also be good because we just write basic getters when we want them to be lazy and reactive. Should we want a getter to be called everytime, we define a normal method. IMPORTANT NOTE: Mutations inside a getter isn't allowed. It might result to infinite loop. TASK-ID: 4361605
- Loading branch information
Showing
15 changed files
with
627 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.