There are cases where the return value of an async operation is not important or not given at all. In those cases, method signatures of async operations often define Observable<any>
or Promise<any>
as return value.
For example the Ionic2 NavController defines:
/** // ...
* @returns {Promise} Returns a promise which is resolved when the transition has completed.
*/
abstract remove(/* ... */): Promise<any>;
Without looking at the actual implementation I cannot tell whether there really is no value emitted (e.g. null
or undefined
) or whether I could extract some useful information from the emitted values.
Observable<void>
?I haven't seen Observable<void>
or Promise<void>
in the wild. By using that it would be clear that there is no useful value being emitted. Are there any technical reasons not to use the void
type with observables? Or why is no one using that to designate empty values?
Are there any technical reasons not to use the void type with observables? Or why is no one using that to designate empty values
There is no hazard in using Promise<void>
as far as I am aware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With