Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding the Page events

Tags:

nativescript

I have been trying to understand the differences between the Page events in Nativescript, the events I am trying to look into are loaded, navigatingTo and navigatedTo. What I have seen, the 3 of them will be fired everytime you navigate to the Page. What I do not understand is in which order they are executed. I know that navigatingTo fires first than navigatedTo, that makes sense, but what about loaded?

Is loaded being fired every time you navigate to the page or just for the first time you navigate to the page?

Is there any event that only executes the first time you navigate to the page? If the app is closed or went to the background and then resumed, it will fire again, of course.

Thanks!!!

like image 882
relez Avatar asked Nov 30 '22 16:11

relez


1 Answers

Supose you are in "Old page" and navigate to "New page", the sequence of events is:

  1. Old page triggers its navigatingFrom
  2. New page triggers its navigatingTo
  3. Old page triggers its unloaded
  4. Old page triggers its navigatedFrom
  5. New page triggers its loaded
  6. New page triggers its navigatedTo

When the app is open, there is no "Old page", so the sequence is:

  1. New page triggers its navigatingTo
  2. New page triggers its loaded
  3. New page triggers its navigatedTo

If app is closed, the app only triggers its unloaded event (you put it in background to close it, or power off the device...)

If you run the app in background, the page triggers its unload event, and when you resume the app, the page triggers its loaded event.

This is my experience, it may not agree with 'reality'

(Updated: See also: {N} v7 Page Events)

like image 115
seros Avatar answered Dec 28 '22 08:12

seros