Would be interested to know if there is any information available on the conditions when a PowerApp attempts to retrieve data from a data source. Based on my scenario below, it appears that the datasources within a screen are triggered (start trying to retrieve data) when a button is selected that contains a command to navigate to that screen, even though the navigate is inside an If statement and so the navigation may not occur.
Scenario
My App has offline and online mode. There are some screens where galleries display data either from the offline (local collection) datasource or the online datasource (in this case Dynamics 365 CE) depending upon connection state.
Initially I had an If statement within the Gallery Items property:
If(Connection.Connected Or Connection.Metered,
Filter(Accounts, Account = ..,
Filter(colAccounts, Account = ...)
However, the App was attempting to read data from the Dynamics Account entity even when the App was in offline mode (resulting in an error).
I therefore created two separate screens, one for offline and one for online. I then put an If statement on the button that calls the screens:
If(Connection.Connected Or Connection.Metered,
Navigate('Select Account',Cover,{conSelectedAccount:conSelectedAccount}),
Navigate('Select Account Online',Cover,{conSelectedAccount:conSelectedAccount}))
Even with this, when the button was pushed in offline mode, the App was still attempting to read data from the Dynamics Account entity (resulting in an error).
Finally I put two buttons on the screen - one to navigate to the screen with the gallery based on the offline data and one to navigate to the screen with the online data. I then set these buttons to be visible depending on the connection state and finally I can prevent the App from trying to retrieve data from the online source while the App is offline.
Some info on exactly what circumstances result in an App attempting to read data would be appreciated.