Hi community
I have a need. I have a page that get an image from device storage, gallery or camera. That page is called by another 3 pages and it save the image using Capacitor Storage. My problem is inform the caller page that the image was saved.
Thanks in advance
Use a service that is injected by both pages.
Thanks a lot. It works as I need
I’m sorry again. I am newbe with ionic. I can’t not make this works; maybe I don’t understand you. I have two pages, page1 calls page2, page2 use camera for taking a photo or load the photo from the device. How can page2 say to page1 that the photo is loaded. I save the photo on the storage. I need to page2 say page1 the photo is loaded then page1 can use and erase the photo.
I tried with Events but is deprecated, and I am not understand the whole observable theme.
You can use subject or behaviorSubject from rxjs to trigger an change to other pages
last one
input and output parent-child communication
Communicate with child with ViewChild Note: child selector must be on parent html
communicate with subject or behaviorSubject across component
To me it’s not clear why page lifecycle should not be/is not capable of solving this issue. As I understand IonViewLoaded is not suitable cause it fires only once and not after a reload. IonViewWillEnter as well as IonViewDidEnter however should be executed everytime a page is navigated to. What requirements does the lifecycle help to satisfy then?
The page lifecycle can be used, but my reason for not using it is the amount of additional code it introduces compared to the state management using behaviorsubject.
Check the pattern as published by @rapropos .
Ionic 4 Tab to page then back to Tab did not trigger ionViewWillEnter [Solved] - #11 by rapropos
Pretty much the only things I do with lifecycle events are things I can’t do anywhere else. Two examples that come to mind are that ngOnChanges
is the only place I can be sure that @Input
bindings have been populated, and ngAfterViewInit
is the first place I can be similarly assured about @ViewChild
.