true, is not async in fact, but this works because await is queuing the call, is like:
ngOnInit()
... some time later...
myFunction resolves and data is populated, so the template is unblocked.
This is like a "hack" and confusing but works because the template has to wait the data.
This scenario is not a default one, blocking the template is not a good practice but in some scenario like the init of an app maybe fits and is not necessary to use Factories.
My main job is not in IT, but I do have a CS degree and have been programming for over 20 years (only born in 1984). I hate dealing with Servers, and want Graph Databases to be the new norm.
The problem is that it is not guaranteed to be resolved before the component is initialized because it is not a REAL async function. Using zone.js will guarantee it gets resolved before the component is loaded. Any other function with async in front of it, IS a real async function. Yes, it is a hack, but sometimes there is no other way.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
true, is not async in fact, but this works because await is queuing the call, is like:
ngOnInit()
... some time later...
myFunction resolves and data is populated, so the template is unblocked.
This is like a "hack" and confusing but works because the template has to wait the data.
This scenario is not a default one, blocking the template is not a good practice but in some scenario like the init of an app maybe fits and is not necessary to use Factories.
The problem is that it is not guaranteed to be resolved before the component is initialized because it is not a REAL async function. Using zone.js will guarantee it gets resolved before the component is loaded. Any other function with
async
in front of it, IS a real async function. Yes, it is a hack, but sometimes there is no other way.