I'm just learning promises, and am stuck with the following scenario. I'll use an example of building a house.
First, I want to build my house. Once my house is completely finished, I will start two projects at the same time: landscaping my yard, and building a pool. If I understand everything so far, that would be:
buildHouse()
.then(function () {
landscapeYard();
buildPool();
}
My problem is now I want to plant flowers only after the yard is completely landscaped. And I want to build a fence around my pool whenever my pool is completely built. Something like this? The pool and yard projects can go on separately, at different paces. Maybe the pool project will take 2 years to finish, and the yard project will take 1 week:
buildHouse()
.then(function () {
landscapeYard();
.then(function () {
plantFlowers();
})
buildPool();
.then(function () {
buildFence();
})
})
Is that correct?
And my final problem is, once BOTH projects are completely finished, I want to start an entirely new project. Thanks for any help.