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

feat: add refresh method #84

Merged
merged 9 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions ember-engines-router-service/src/services/engine-router-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ export default class EngineRouterService extends Service.extend(Evented) {
return this._externalRoutes[externalRouteName];
}

refresh(routeName = this.currentRouteName, ...args) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this approach might be able to solve #74 as well @SergeAstapov if you want I can add it as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aklkv sure, feel free to open separate PR, to keep each PR focused on one thing

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @SergeAstapov here, let's open another PR for this purpose

if (resemblesURL(routeName)) {
return this.externalRouter.refresh(routeName);
}

return this.externalRouter.refresh(
namespaceEngineRouteName(this._mountPoint, routeName),
...args
);
}

refreshExternal(routeName, ...args) {
return this.externalRouter.refresh(
this.getExternalRouteName(routeName),
...args
);
}

transitionTo(routeName, ...args) {
if (resemblesURL(routeName)) {
return this.externalRouter.transitionTo(routeName);
Expand Down
10 changes: 6 additions & 4 deletions ember-engines-router-service/types/services/router.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type RouterService from '@ember/routing/router-service';

export default interface EnginesRouterService extends Omit<
RouterService,
"currentRoute" | "recognize" | "recognizeAndLoad"
> {
export default interface EnginesRouterService
extends Omit<
RouterService,
'currentRoute' | 'recognize' | 'recognizeAndLoad'
> {
isActiveExternal: RouterService['isActive'];
replaceWithExternal: RouterService['replaceWith'];
transitionToExternal: RouterService['transitionTo'];
refreshExternal: RouterService['refresh'];
urlForExternal: RouterService['urlFor'];
}