I want to convert Observable to User[].
After googling, I found a solution BUT, the conversion is done only inside map.
users : User[] = [];
this.userService.getUsersList() // Observable<Any>
.map((listUsers: Array<any>) => {
let result:Array<User> = [];
if (listUsers) {
listUsers.forEach((erg) => {
result.push(new User(erg.id, erg.name, erg.username, erg.email, erg.password, erg.age, erg.active, erg.roles));
});
}
console.log('----------------Size: ' + result.length); // Output: 5 --> TRUE
return result;
})
.subscribe(users => this.users = users);
console.log('----------------Size: ' + result.length); // Output: 0 --> FALSE
So it's Ok, I can get the size of the array User[] inside map. My problem is, how can I get the size or read the array User[] outside map.
Thanks in advance.