Ionic app loading sequence

That’s not the way I would think of it. Any time you call a function that returns a future (Promise or Observable), you have three choices:

  • I don’t care when it returns, or with what. Declare your function to return void and accept that nobody has any idea when the future will resolve.

  • I care, but only within the confines of this function. Declare your function to return void, and handle absolutely everything needing the resolved value inside a then or subscribe block.

  • I care, and so does whoever is calling me. In this case, declare your function to also return some sort of future, and make the very first word you type in the body be return. I don’t care if that feels awkward at first, but if you follow this rule, you will save yourself from 98% of future-related bugs and organically learn the proper operators and idioms to transform futures properly.

4 Likes