Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add refresh method to router service #631

Merged
merged 8 commits into from
Oct 9, 2020
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions text/0631-refresh-method-for-router-service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
- Start Date: 2020-05-23
- Relevant Team(s): Ember.js
- RFC PR: https://github.com/emberjs/rfcs/pull/631
- Tracking: (leave this empty)

# RouterService#refresh

## Summary

> Add a refresh method to the router service that calls refresh on all currently active routes.

## Motivation

> We want to be able to call refresh on all currently active routes from a centralized service
or from a component. As a side benefit, we will be able to do this without relying on the send api,
which is being discussed as a possible deprecation in RFC 632.
Gaurav0 marked this conversation as resolved.
Show resolved Hide resolved
This enables us to get the latest data from the model hook.

## Detailed design

```js
class RouterService {
refresh() {
this._router._routerMicroLib.refresh();
}
}
```

## How we teach this

> The following documentation will be added to the method:

```js
/**
* Refreshes all currently active routes, doing a full transition.
* All resetController, beforeModel, model, afterModel, redirect, and setupController
* hooks will be called again. You will get new data from the model hook.
*
* @method refresh
* @public
*/
```

## Drawbacks

> This is a slight increase in API surface area.

## Alternatives

> We could provide a direct link to the current route via the router service. However,
this would encourage people to use routes to store information and provide methods
that should be idiomatically placed in a service.