@@ -14,7 +14,7 @@ interface SubscriptionStrategy {
1414}
1515
1616class ObservableStrategy implements SubscriptionStrategy {
17- createSubscription ( async : ObservableOrPromise < any > , next : any , error : any , complete : any ) : SubscriptionLike {
17+ createSubscription ( async : Observable < any > , next : any , error : any , complete : any ) : SubscriptionLike {
1818 return async . subscribe ( next , error , complete ) ;
1919 }
2020
@@ -26,8 +26,14 @@ class ObservableStrategy implements SubscriptionStrategy {
2626}
2727
2828class PromiseStrategy implements SubscriptionStrategy {
29- createSubscription ( async : Observable < any > | Promise < any > , next : any , error : any , complete : any ) : Promise < any > {
30- return async . then ( next , error ) . finally ( complete ) ;
29+ createSubscription ( async : Promise < any > , next : any , error : any , complete : any ) : Promise < any > {
30+ const promise = async . then ( next , error ) ;
31+
32+ if ( 'finally' in promise ) {
33+ return ( promise as any ) . finally ( complete ) ;
34+ }
35+
36+ return promise ;
3137 }
3238
3339 dispose ( subscription : Promise < any > ) : void { }
@@ -97,7 +103,7 @@ export class AsyncDirective implements OnChanges, OnDestroy {
97103 }
98104 }
99105
100- private subscribe ( async : ObservableOrPromise < async > ) {
106+ private subscribe ( async : ObservableOrPromise < any > ) {
101107 this . strategy = resolveStrategy ( async ) ;
102108 this . subscription = this . strategy . createSubscription (
103109 async ,
0 commit comments