mirror of
https://github.com/SARL-PACIFIC-ERP/odoo-sh-test.git
synced 2025-06-25 09:32:22 +00:00
ch2.5 Cache network calls, create a service
This commit is contained in:
parent
7d74834fb7
commit
100ce00a11
|
@ -17,9 +17,9 @@ class AwesomeDashboard extends Component {
|
|||
|
||||
this.action = useService("action");
|
||||
|
||||
this.rpc = useService('rpc');
|
||||
this.stats = useService('awesome_dashboard.statistics');
|
||||
onWillStart(async () => {
|
||||
this.stats = await this.rpc("/awesome_dashboard/statistics");
|
||||
this.stats = await this.stats.loadStatistics();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
17
awesome_dashboard/static/src/statistics_service.js
Normal file
17
awesome_dashboard/static/src/statistics_service.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
import { memoize } from "@web/core/utils/functions"
|
||||
|
||||
const statisticsService = {
|
||||
dependencies: ["rpc"],
|
||||
async: ["loadStatistics"],
|
||||
start(env, { rpc }) {
|
||||
return {
|
||||
loadStatistics: memoize(() => rpc("/awesome_dashboard/statistics")),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
registry.category("services").add("awesome_dashboard.statistics", statisticsService);
|
Loading…
Reference in a new issue