File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -37,5 +37,13 @@ export default {
37
37
required: true ,
38
38
},
39
39
},
40
+ watch: {
41
+ item: {
42
+ handler (newValue ) {
43
+ this .$emit (' change' , newValue);
44
+ },
45
+ deep: true ,
46
+ },
47
+ },
40
48
};
41
49
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<loading-indicator v-if =" isLoading" message =" Loading movies..." />
3
3
<div v-else class =" row" >
4
- <movie-item v-for =" movie in movies" :item =" movie" :key =" movie.id" />
4
+ <movie-item
5
+ v-for =" movie in movies"
6
+ :item =" movie"
7
+ :key =" movie.id"
8
+ @change =" onChange"
9
+ />
5
10
</div >
6
11
</template >
7
12
8
13
<script >
9
- import { getMovies } from ' @/api' ;
14
+ import { getMovies , saveMovie } from ' @/api' ;
10
15
import MovieItem from ' @/components/MovieItem.vue' ;
11
16
import LoadingIndicator from ' @/components/LoadingIndicator.vue' ;
12
17
@@ -29,5 +34,10 @@ export default {
29
34
this .isLoading = false ;
30
35
});
31
36
},
37
+ methods: {
38
+ onChange (movie ) {
39
+ saveMovie (movie);
40
+ },
41
+ },
32
42
};
33
43
</script >
You can’t perform that action at this time.
0 commit comments