Skip to content

Commit

Permalink
fix: add warning message for ember-source below v4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aklkv committed Nov 3, 2023
1 parent 5448fe0 commit d08cbf3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ember-engines-router-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"start": "rollup --config --watch"
},
"dependencies": {
"@embroider/addon-shim": "^1.8.4"
"@embroider/addon-shim": "^1.8.4",
"@embroider/macros": "^1.13.2"
},
"devDependencies": {
"@babel/core": "^7.20.7",
Expand Down
13 changes: 13 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 @@ -5,10 +5,15 @@ import { action, computed } from '@ember/object';
import { reads } from '@ember/object/computed';
import { getOwner } from '@ember/application';
import Evented from '@ember/object/evented';
import { macroCondition, dependencySatisfies } from '@embroider/macros';
import { namespaceEngineRouteName } from '../utils/namespace-engine-route-name';
import { getRootOwner } from '../utils/root-owner';
import { resemblesURL } from '../utils/resembles-url';

const hasRefreshMethod = macroCondition(
dependencySatisfies('ember-source', '>=4.1.0')
);

export default class EngineRouterService extends Service.extend(Evented) {
constructor(...args) {
super(...args);
Expand Down Expand Up @@ -66,6 +71,10 @@ export default class EngineRouterService extends Service.extend(Evented) {
}

refresh(routeName = this.currentRouteName, ...args) {
if (!hasRefreshMethod) {
assert('Refresh method is not available in ember-source below v4.1');
}

if (resemblesURL(routeName)) {
return this.externalRouter.refresh(routeName);
}
Expand All @@ -77,6 +86,10 @@ export default class EngineRouterService extends Service.extend(Evented) {
}

refreshExternal(routeName, ...args) {
if (!hasRefreshMethod) {
assert('Refresh method is not available in ember-source below v4.1');
}

return this.externalRouter.refresh(
this.getExternalRouteName(routeName),
...args
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@
typescript-memoize "^1.0.1"
walk-sync "^3.0.0"

"@embroider/[email protected]", "@embroider/macros@^1.0.0", "@embroider/macros@^1.10.0", "@embroider/macros@^1.13.0", "@embroider/macros@^1.3.0":
"@embroider/[email protected]", "@embroider/macros@^1.0.0", "@embroider/macros@^1.10.0", "@embroider/macros@^1.13.0", "@embroider/macros@^1.13.2", "@embroider/macros@^1.3.0":
version "1.13.2"
resolved "https://registry.yarnpkg.com/@embroider/macros/-/macros-1.13.2.tgz#07dda11313a2539f403404881b729e622a80ca17"
integrity sha512-AUgJ71xG8kjuTx8XB1AQNBiebJuXRfhcHr318dCwnQz9VRXdYSnEEqf38XRvGYIoCvIyn/3c72LrSwzaJqknOA==
Expand Down

0 comments on commit d08cbf3

Please sign in to comment.