31 lines
551 B
JavaScript
31 lines
551 B
JavaScript
class Controller {
|
|
constructor(view,model){
|
|
this.view = view
|
|
this.model = model
|
|
|
|
this.loading = false
|
|
this.lastSearch = null
|
|
this.error = null
|
|
this.results = []
|
|
|
|
this.view.setLoading(false)
|
|
this.view.bindSearch(this.search.bind(this))
|
|
}
|
|
reset() {
|
|
this.loading = false
|
|
this.error = null
|
|
this.results = []
|
|
}
|
|
|
|
async search(searchMovie) {
|
|
let data = await this.model.getMovies(searchMovie);
|
|
console.log(data);
|
|
if (data.Response === "True"){
|
|
this.view.renderList(data.Search);
|
|
}
|
|
}
|
|
}
|
|
|
|
export default Controller
|
|
|