Skip to content

Commit e3697cc

Browse files
committed
routes/application: Preload Rust Playground crates list after the app has been open for 1 sec
1 parent 4c535f4 commit e3697cc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

app/routes/application.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import Route from '@ember/routing/route';
33
import { inject as service } from '@ember/service';
44

55
import * as Sentry from '@sentry/browser';
6+
import { rawTimeout, task } from 'ember-concurrency';
67

78
export default class ApplicationRoute extends Route {
89
@service progress;
910
@service router;
1011
@service session;
12+
@service playground;
1113

1214
beforeModel() {
1315
this.router.on('routeDidChange', () => {
@@ -24,10 +26,21 @@ export default class ApplicationRoute extends Route {
2426
//
2527
// eslint-disable-next-line ember-concurrency/no-perform-without-catch
2628
this.session.loadUserTask.perform();
29+
30+
// trigger the preload task, but don't wait for the task to finish.
31+
this.preloadPlaygroundCratesTask.perform().catch(() => {
32+
// ignore all errors since we're only preloading here
33+
});
2734
}
2835

2936
@action loading(transition) {
3037
this.progress.handle(transition);
3138
return true;
3239
}
40+
41+
@task(function* () {
42+
yield rawTimeout(1000);
43+
yield this.playground.loadCratesTask.perform();
44+
})
45+
preloadPlaygroundCratesTask;
3346
}

0 commit comments

Comments
 (0)