You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next, at the end of the `usePhotoGallery()` method, add a call to the `cachePhotos` method to save the `photos` array. By adding it here, the `photos` array is stored each time a new photo is taken. This way, it doesn’t matter when the app user closes or switches to a different app - all photo data is saved.
34
34
35
35
```ts
36
36
exportconst usePhotoGallery = () => {
37
-
//Same old code from before.
37
+
//...existing code...
38
38
39
39
// CHANGE: Add `cachePhotos()` method.
40
40
const cachePhotos = () => {
@@ -57,7 +57,7 @@ Add the call to the `watch()` method above the return statement in `usePhotoGall
57
57
58
58
```ts
59
59
exportconst usePhotoGallery = () => {
60
-
//Same old code from before.
60
+
//...existing code...
61
61
62
62
// CHANGE: Add call to `watch` with `photos` array and `cachePhotos` method.
63
63
watch(photos, cachePhotos);
@@ -73,7 +73,7 @@ With the photo array data saved, create a new method in the `usePhotoGallery()`
73
73
74
74
```ts
75
75
exportconst usePhotoGallery = () => {
76
-
//Same old code from before.
76
+
//...existing code...
77
77
78
78
// CHANGE: Add `loadSaved()` method.
79
79
const loadSaved =async () => {
@@ -94,7 +94,7 @@ On mobile (coming up next!), we can directly set the source of an image tag - `<
Copy file name to clipboardExpand all lines: docs/vue/your-first-app/7-live-reload.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ import { isPlatform } from '@ionic/vue';
46
46
import { Capacitor } from'@capacitor/core';
47
47
48
48
exportconst usePhotoGallery = () => {
49
-
//Same old code from before.
49
+
//...existing code...
50
50
51
51
// CHANGE: Add `deletePhoto()` method.
52
52
const deletePhoto =async (photo:UserPhoto) => {
@@ -81,7 +81,7 @@ export interface UserPhoto {
81
81
Next, in `Tab2Page.vue`, implement the `showActionSheet()` method. We're adding two options: "Delete", which calls `usePhotoGallery.deletePicture()`, and "Cancel". The cancel button will automatically closes the action sheet when assigned the "cancel" role.
82
82
83
83
```vue
84
-
<!-- Same old code from before. -->
84
+
<!-- ...existing code... -->
85
85
86
86
<script setup lang="ts">
87
87
import { camera, trash, close } from 'ionicons/icons';
Next, at the end of the `usePhotoGallery()` method, add a call to the `cachePhotos` method to save the `photos` array. By adding it here, the `photos` array is stored each time a new photo is taken. This way, it doesn’t matter when the app user closes or switches to a different app - all photo data is saved.
34
34
35
35
```ts
36
36
exportconst usePhotoGallery = () => {
37
-
//Same old code from before.
37
+
//...existing code...
38
38
39
39
// CHANGE: Add `cachePhotos()` method.
40
40
const cachePhotos = () => {
@@ -57,7 +57,7 @@ Add the call to the `watch()` method above the return statement in `usePhotoGall
57
57
58
58
```ts
59
59
exportconst usePhotoGallery = () => {
60
-
//Same old code from before.
60
+
//...existing code...
61
61
62
62
// CHANGE: Add call to `watch` with `photos` array and `cachePhotos` method.
63
63
watch(photos, cachePhotos);
@@ -73,7 +73,7 @@ With the photo array data saved, create a new method in the `usePhotoGallery()`
73
73
74
74
```ts
75
75
exportconst usePhotoGallery = () => {
76
-
//Same old code from before.
76
+
//...existing code...
77
77
78
78
// CHANGE: Add `loadSaved()` method.
79
79
const loadSaved =async () => {
@@ -94,7 +94,7 @@ On mobile (coming up next!), we can directly set the source of an image tag - `<
Copy file name to clipboardExpand all lines: versioned_docs/version-v7/vue/your-first-app/7-live-reload.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ import { isPlatform } from '@ionic/vue';
46
46
import { Capacitor } from'@capacitor/core';
47
47
48
48
exportconst usePhotoGallery = () => {
49
-
//Same old code from before.
49
+
//...existing code...
50
50
51
51
// CHANGE: Add `deletePhoto()` method.
52
52
const deletePhoto =async (photo:UserPhoto) => {
@@ -81,7 +81,7 @@ export interface UserPhoto {
81
81
Next, in `Tab2Page.vue`, implement the `showActionSheet()` method. We're adding two options: "Delete", which calls `usePhotoGallery.deletePicture()`, and "Cancel". The cancel button will automatically closes the action sheet when assigned the "cancel" role.
82
82
83
83
```vue
84
-
<!-- Same old code from before. -->
84
+
<!-- ...existing code... -->
85
85
86
86
<script setup lang="ts">
87
87
import { camera, trash, close } from 'ionicons/icons';
0 commit comments