If I have an array of arrays like this
{
parent: [
{
name: 'stu',
children: [
{name: 'bob'},
{name: 'sarah'}
]
},
{
...
}
]
}
and I want to cycle through each parent and cycle through their children in series, so that I don't start the next parent until all the children have been processed (some long asynchronous process), how do I do this with RxJS?
I have attempted this:
var doChildren = function (parent) {
console.log('process parent', parent.name);
rx.Observable.fromArray(parent.children)
.subscribe(function (child) {
console.log('process child', child.name);
// do some Asynchronous stuff in here
});
};
rx.Observable.fromArray(parents)
.subscribe(doChildren);
But I get all the parents logging out and then all the children.