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';
22import Route from '@ember/routing/route' ;
33import { inject as service } from '@ember/service' ;
44
5+ import { didCancel , rawTimeout , task } from 'ember-concurrency' ;
6+
57export default class ApplicationRoute extends Route {
68 @service progress ;
79 @service session ;
10+ @service playground ;
811
912 beforeModel ( ) {
1013 // trigger the task, but don't wait for the result here
@@ -15,10 +18,22 @@ export default class ApplicationRoute extends Route {
1518 //
1619 // eslint-disable-next-line ember-concurrency/no-perform-without-catch
1720 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+ } ) ;
1827 }
1928
2029 @action loading ( transition ) {
2130 this . progress . handle ( transition ) ;
2231 return true ;
2332 }
33+
34+ @task ( function * ( ) {
35+ yield rawTimeout ( 1000 ) ;
36+ this . playground . loadCrates ( ) ;
37+ } )
38+ preloadPlaygroundCratesTask ;
2439}
You can’t perform that action at this time.
0 commit comments