Skip to content

Reduce class size by extracting respective render logic #4

@Toastbroad

Description

@Toastbroad

handleMovieData(movieData, bookData, albumData, comicData) {
console.log('movieData: ', movieData);
this.renderSearchFilmTemplate(
movieData.Poster,
movieData.Title,
movieData.Rated,
movieData.Genre,
movieData.Runtime,
movieData.Plot,
movieData.Director,
movieData.Writer,
movieData.Actors,
movieData.Year
);
console.log('bookData: ', bookData);
this.renderSearchBookTemplate(
bookData.items[0].volumeInfo.title,
bookData.items[0].volumeInfo.imageLinks.thumbnail,
bookData.items[0].volumeInfo.authors,
bookData.items[0].volumeInfo.categories,
bookData.items[0].volumeInfo.ratingsCount,
bookData.items[0].volumeInfo.pageCount,
bookData.items[0].volumeInfo.publishedDate
);
console.log('albumData: ', albumData);
this.renderSearchAlbumTemplate(
albumData.results[1].title,
albumData.results[1].cover_image
//albumData.results[0].artist,
);
console.log('comicData: ', comicData);
}

This should actually be the last method (except for the render method) in this class. Try and extract the respective render logic into its own place (class, function, ...) and import that. This way, this class does not have to know about the how (check out Law of Demeter, Single Responsibility Principle)...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions