Closed mangeleptico closed 3 years ago
@mangeleptico
I had the same problem before :) You can use filter operator from RxJS to get the resources when it has been "built & loaded" before assign it to your data variable
authorsService
.all({
include: ['books'],
sort: ['name'],
page: { number: page || 1 },
ttl: 3600
})
.pipe(
filter(authors => authors.loaded), // Only get the response when every resources are loaded !
)
.subscribe(
authors => {
this.authors = authors;
},
error => console.error('Could not load authors :(', error)
);
Thanks! its works for me. It's necessary too use a conditional of authors in html if i want to print authors data on screen to avoid asynchronous errors
Hi,
If I try to user filter(), I have an error:
TypeError: filter is not a function. (In 'filter(function (authors) { return authors.loaded; })', 'filter' is undefined)
When i try to access to any element of authors array, the response is undefined, only works when i change to books table and then return to authors. This happends with all get a collection of resources
example: ` public authors: DocumentCollection;