44 */
55
66import Service from '@ember/service' ;
7- import { task , timeout } from 'ember-concurrency' ;
7+ import { dropTask , timeout } from 'ember-concurrency' ;
88import { tracked } from '@glimmer/tracking' ;
99import { DateTime } from 'luxon' ;
1010import { isTesting } from '@embroider/macros' ;
11- import type { TaskGenerator } from 'ember-concurrency' ;
1211import type {
1312 DisplayType ,
1413 DefaultDisplayType ,
@@ -226,12 +225,11 @@ export default class TimeService extends Service {
226225 }
227226
228227 // Subscribes a listener to the ticking task for time changes.
229- register ( id : Date ) : ( ) => void {
228+ async register ( id : Date ) : Promise < ( ) => void > {
230229 this . #listeners. add ( id ) ;
231- // @ts -expect-error - TS2339: Property 'perform' does not exist on type '() => TaskGenerator<string | undefined>'
232- // note: we could potentially use taskFor via `ember-concurrency-ts` to avoid this exception
233- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
234- this . start . perform ( ) ;
230+
231+ await this . start . perform ( ) ;
232+
235233 return ( ) : void => {
236234 this . unregister ( id ) ;
237235 } ;
@@ -242,18 +240,17 @@ export default class TimeService extends Service {
242240 return this . #listeners. delete ( id ) ;
243241 }
244242
245- @task ( { drop : true } )
246- * start ( ) : TaskGenerator < string | undefined > {
243+ start = dropTask ( async ( ) => {
247244 while ( this . listeners . size ) {
248245 this . now = Date . now ( ) ;
249246 // When testing and canceling a EC task, a timer will never resolve and
250247 // cause the test to hang while waiting for a permanently hanging timeout.
251248 // This condition breaks the test out of that.
252249 // via: http://ember-concurrency.com/docs/testing-debugging/
253250 if ( isTesting ( ) ) return ;
254- yield timeout ( SECOND_IN_MS ) ;
251+ await timeout ( SECOND_IN_MS ) ;
255252 }
256- }
253+ } ) ;
257254
258255 // Transforms a JS date to a string representing the UTC ISO date.
259256 toIsoUtcString ( date : Date ) : string | undefined {
0 commit comments