File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,12 @@ import { action } from '@ember/object';
2
2
import Route from '@ember/routing/route' ;
3
3
import { inject as service } from '@ember/service' ;
4
4
5
+ import { didCancel , rawTimeout , task } from 'ember-concurrency' ;
6
+
5
7
export default class ApplicationRoute extends Route {
6
8
@service progress ;
7
9
@service session ;
10
+ @service playground ;
8
11
9
12
beforeModel ( ) {
10
13
// trigger the task, but don't wait for the result here
@@ -15,10 +18,22 @@ export default class ApplicationRoute extends Route {
15
18
//
16
19
// eslint-disable-next-line ember-concurrency/no-perform-without-catch
17
20
this . session . loadUserTask . perform ( ) ;
21
+
22
+ // trigger the preload task, but don't wait for the task to finish.
23
+ this . preloadPlaygroundCratesTask . perform ( ) . catch ( error => {
24
+ // ignore task cancellation errors
25
+ if ( ! didCancel ( error ) ) throw error ;
26
+ } ) ;
18
27
}
19
28
20
29
@action loading ( transition ) {
21
30
this . progress . handle ( transition ) ;
22
31
return true ;
23
32
}
33
+
34
+ @task ( function * ( ) {
35
+ yield rawTimeout ( 1000 ) ;
36
+ this . playground . loadCrates ( ) ;
37
+ } )
38
+ preloadPlaygroundCratesTask ;
24
39
}
You can’t perform that action at this time.
0 commit comments