I am facing a challenge with a list of books that have IsEnable defaulting to False. During onInit(), I need to check each book to see if it is enabled. I was considering using an rxjs map and calling the getEligibleBooks() function within the map, but I am unsure how to assign the return value (true or false) to the IsEnable property.
Books.ts
export class Book{
Name:string;
IsEnable:boolean;
}
books.component.ts
...
books = Observable.of([{"Name":"A", "IsEnable":"False"},{"Name":"B", "IsEnable":"False"}]);
...
getEligibleBooks(book){
//complex logic
return result; //true or false
}
...
ngOnInit(){
this.books.pipe(
map( book => this.getEligibleBooks(book)) // have no idea how to achieve it
).subscribe(data=>console.log(data));
}