Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cf1cdfc

Browse files
committedMar 20, 2021
Add documentation to the README
1 parent 5b3a0cf commit cf1cdfc

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed
 

‎README.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
ember-router-service-refresh-polyfill
22
==============================================================================
33

4-
[Short description of the addon.]
4+
Polyfills the RouterService#refresh method as described in [RFC 631](https://emberjs.github.io/rfcs/0631-refresh-method-for-router-service.html).
55

66

77
Compatibility
88
------------------------------------------------------------------------------
99

10-
* Ember.js v3.16 or above
11-
* Ember CLI v2.13 or above
10+
* Ember.js v3.4 or above
11+
* Ember CLI v3.4 or above
1212
* Node.js v10 or above
1313

1414

@@ -23,8 +23,36 @@ ember install ember-router-service-refresh-polyfill
2323
Usage
2424
------------------------------------------------------------------------------
2525

26-
[Longer description of how to use the addon in apps.]
26+
This addon polyfills the RouterService#refresh method which refreshes all currently active routes, doing a full transition.
2727

28+
If a `routeName` is provided and refers to a currently active route,
29+
it will refresh only that route and its descendents.
30+
31+
It returns a [Transition](https://api.emberjs.com/ember/release/classes/Transition) that will be resolved once the refresh is complete.
32+
All resetController, beforeModel, model, afterModel, redirect, and setupController
33+
hooks will be called again. You will get new data from the model hook.
34+
35+
### Example
36+
37+
```js
38+
import Component from '@glimmer/component';
39+
import { inject as service } from '@ember/service';
40+
import { action } from '@ember/object';
41+
42+
export default class VeryRealComponent extends Component {
43+
@service('router') routerService;
44+
45+
@action
46+
refreshAllActiveRoutes() {
47+
this.routerService.refresh();
48+
}
49+
50+
@action
51+
refreshNamedActiveRoute() {
52+
this.routerService.refresh('some-active-route-name');
53+
}
54+
}
55+
```
2856

2957
Contributing
3058
------------------------------------------------------------------------------

0 commit comments

Comments
 (0)
Please sign in to comment.