-
Notifications
You must be signed in to change notification settings - Fork 31
chore: 🤖 create patched ember-loading to use modern ember-concurrency #3015
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
Open
hashicc
wants to merge
1
commit into
main
Choose a base branch
from
patch-ember-loading
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
diff --git a/addon/services/loading.ts b/addon/services/loading.ts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
index 34ac7eb0cdf4ee8f09661ba2459068307bb2792e..9d201c99046fb2e3d6ba3b49f8c1445a4c768c02 100644 | ||
--- a/addon/services/loading.ts | ||
+++ b/addon/services/loading.ts | ||
@@ -4,7 +4,6 @@ import { restartableTask, task, timeout } from 'ember-concurrency'; | ||
import RouterService from '@ember/routing/router-service'; | ||
import { getOwner } from '@ember/application'; | ||
import RSVP, { defer } from 'rsvp'; | ||
-import { taskFor } from 'ember-concurrency-ts'; | ||
|
||
type ParseArgsValue = [any, Function, any[] | undefined]; | ||
|
||
@@ -49,7 +48,6 @@ function parseArgs(): ParseArgsValue { | ||
} | ||
|
||
export default class LoadingService extends Service { | ||
- | ||
@service | ||
router!: RouterService; | ||
|
||
@@ -58,11 +56,11 @@ export default class LoadingService extends Service { | ||
watchTransitions = true; | ||
|
||
get isLoading(): boolean { | ||
- return taskFor(this._runJob).isRunning; | ||
+ return this._runJob.isRunning; | ||
} | ||
|
||
get showLoading(): boolean { | ||
- return !taskFor(this.preDelayTask).isRunning && (this.isLoading || taskFor(this.postDelayTask).isRunning); | ||
+ return !this.preDelayTask.isRunning && (this.isLoading || this.postDelayTask.isRunning); | ||
} | ||
|
||
_routerTransitionDeferred?: RSVP.Deferred<unknown>; | ||
@@ -132,33 +130,30 @@ export default class LoadingService extends Service { | ||
// run<R>(fn: () => R): Promise<R>; | ||
async run(...args: any[]) { | ||
if (this.preDelay > 0) { | ||
- taskFor(this.preDelayTask).perform(this.preDelay); | ||
+ this.preDelayTask.perform(this.preDelay); | ||
} | ||
|
||
- let result = await taskFor(this._runJob).perform(...args); | ||
+ let result = await this._runJob.perform(...args); | ||
|
||
if (this.postDelay > 0) { | ||
- taskFor(this.postDelayTask).perform(this.postDelay); | ||
+ this.postDelayTask.perform(this.postDelay); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
- @task | ||
- async _runJob(...args: unknown[]): Promise<unknown> { | ||
+ _runJob = task(async (...args: unknown[]) => { | ||
let [target, method, realArgs] = parseArgs(...args); | ||
return await method.apply(target, realArgs); | ||
- } | ||
+ }); | ||
|
||
- @restartableTask | ||
- async preDelayTask(delay: number): Promise<void> { | ||
+ preDelayTask = restartableTask(async (delay: number) => { | ||
await timeout(delay); | ||
- } | ||
+ }); | ||
|
||
- @restartableTask | ||
- async postDelayTask(delay: number): Promise<void> { | ||
+ postDelayTask = restartableTask(async (delay: number) => { | ||
await timeout(delay); | ||
- } | ||
+ }); | ||
} | ||
|
||
// DO NOT DELETE: this is how TypeScript knows how to look up your services. | ||
diff --git a/index.js b/index.js | ||
index 0ca063d427d9441b9b3a1274bfcfe47186623c63..ca80a9382c6f5e64504048e0757215b1272fb849 100644 | ||
--- a/index.js | ||
+++ b/index.js | ||
@@ -2,4 +2,11 @@ | ||
|
||
module.exports = { | ||
name: require('./package').name, | ||
+ options: { | ||
+ babel: { | ||
+ plugins: [ | ||
+ require.resolve('ember-concurrency/async-arrow-task-transform'), | ||
+ ], | ||
+ }, | ||
+ }, | ||
}; | ||
Comment on lines
+84
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
diff --git a/package.json b/package.json | ||
index 3b898dce9a160776192437af4c35b2038eb39232..2a37d3d6f179bfe62479c5141d705a2d3e4eeaeb 100644 | ||
--- a/package.json | ||
+++ b/package.json | ||
@@ -31,10 +31,10 @@ | ||
"dependencies": { | ||
"ember-cli-babel": "^7.26.6", | ||
"ember-cli-htmlbars": "^5.7.1", | ||
- "ember-cli-typescript": "^4.1.0", | ||
- "ember-concurrency": "^2.0.3", | ||
- "ember-concurrency-async": "^1.0.0", | ||
- "ember-concurrency-ts": "^0.3.0" | ||
+ "ember-cli-typescript": "^4.1.0" | ||
+ }, | ||
+ "peerDependencies": { | ||
+ "ember-concurrency": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ember/optional-features": "2.0.0", |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? It looks like you changed the
ember-loading
package.json to instead makeember-concurrency
a peer dep, would it not just load our app's version now?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I treated the patch as what the package output should be, but unfortunately the way the patches are resolved don't impact how the dependencies are managed and stored in the lockfile. Aside from changing the version I wanted to hint at that
ember-concurrency-async
andember-concurrency-ts
shouldn't be used, but those are also in the lockfile still. If this is more confusing than helpful I can remove the dependency changes from thepackage.json
patch