public Promise < String > getSalutation ( ) { final Deferred < String > d = q . defer ( ) ; Timer timer = new Timer ( ) { @ Override public void run ( ) { d . progress ( new TimerProgress ( "Loaded salutation" , this ) ) ; d . resolve ( "Hello" ) ; } } ; d . progress ( new TimerProgress ( "Loading salutation..." , timer ) ) ; timer . schedule ( 1000 ) ; return d . promise ( ) ; }
Returns a promise of salutation by simulating an asynchronous call with a time - out .