@@ -199,22 +199,23 @@ Let's improve the dashboard by adding a few dashboard items to display *real* bu
199
199
The `awesome_dashboard ` addon provides a `/awesome_dashboard/statistics ` route that is meant
200
200
to return some interesting information.
201
201
202
- To call a specific controller, we need to use the :ref: `rpc service <frontend/services/rpc >`.
202
+ To call a specific controller, we need to use the :ref: `rpc <frontend/services/rpc >` function .
203
203
It only exports a single function that perform the request: :code: `rpc(route, params, settings) `.
204
204
A basic request could look like this:
205
205
206
206
.. code-block :: js
207
207
208
+ import { rpc } from " @web/core/network/rpc" ;
209
+ // ...
210
+
208
211
setup () {
209
- this .rpc = useService (" rpc" );
210
- onWillStart (async () => {
211
- const result = await this .rpc (" /my/controller" , {a: 1 , b: 2 });
212
- // ...
213
- });
212
+ onWillStart (async () => {
213
+ const result = await rpc (" /my/controller" , {a: 1 , b: 2 });
214
+ })
215
+ // ...
214
216
}
215
217
216
- #. Update `Dashboard ` so that it uses the `rpc ` service.
217
- #. Call the statistics route `/awesome_dashboard/statistics ` in the `onWillStart ` hook.
218
+ #. Update `Dashboard ` so that it uses the `rpc ` function and call the statistics route `/awesome_dashboard/statistics `.
218
219
#. Display a few cards in the dashboard containing:
219
220
220
221
- Number of new orders this month
@@ -227,7 +228,7 @@ A basic request could look like this:
227
228
:align: center
228
229
229
230
.. seealso ::
230
- `Code: rpc service <{GITHUB_PATH}/addons/web/static/src/core/network/rpc_service .js >`_
231
+ `Code: rpc <{GITHUB_PATH}/addons/web/static/src/core/network/rpc .js >`_
231
232
232
233
5. Cache network calls, create a service
233
234
========================================
0 commit comments