Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 263
Registered: ‎05-18-2011
My Device: Curve 9300, BB10 Dev Alpha C, Z10

Where to place an http request right after the app has completed loading?

Hi guys,

 

My app needs to automatically make an http request right after it has completed loading (e.g., finished loading UI components and QML...). Is there a signal that lets the app knows that it's finished the loading and ready for making an http request? In other words, where should I place that http call?

 

thanks,

--tom
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Where to place an http request right after the app has completed loading?

[ Edited ]

ui components have an onCreationCompleted signal, for example.

 

but as network requests are async anyhow you could just trigger it at startup and don't worry about the UI, as it is handled in yet another thread.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 263
Registered: ‎05-18-2011
My Device: Curve 9300, BB10 Dev Alpha C, Z10

Re: Where to place an http request right after the app has completed loading?

[ Edited ]

So, Do you mean there is no such the signal? Simon

 

If use onCreationCompleted:

1. Not sure if this signal is fired only once for the entire app life because we want to call http once.

2. Not sure if this signals also means the app's finished loading, we want to make sure this before making http call because the http call uses data, ui components that must be avaliable.

 

Thanks

--tom
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Where to place an http request right after the app has completed loading?

each ui component has this signal. if you need certain elements to be present you can check for them.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 263
Registered: ‎05-18-2011
My Device: Curve 9300, BB10 Dev Alpha C, Z10

Re: Where to place an http request right after the app has completed loading?

[ Edited ]

Looks quite complicated for a simple but standard need! Why don't bb10 has that standard signal? Or maybe we don't know?

--tom
New Contributor
Posts: 6
Registered: ‎02-13-2013
My Device: Dev Alpha B
My Carrier: T-Mobile HR

Re: Where to place an http request right after the app has completed loading?

I believe this could be simply acheived if you assign a method to onCreationCompleted of your main page (ie. the root element of your main.qml).

 

eg.:

import bb.cascades 1.0

Page {
  id: root
  titleBar: TitleBar { tite: "Main page" }
  
  [...]

  onCreationCompleted: {
    console.log("Main page loaded");
    // perform the HTTP request from here
  }
}

 This will for certain happen only once - when the app opens.

 

You could also do it from C++, calling your method right after the usual app->setScene(root); call.



@liio, developer of Push to BB
Developer
Posts: 263
Registered: ‎05-18-2011
My Device: Curve 9300, BB10 Dev Alpha C, Z10

Re: Where to place an http request right after the app has completed loading?

Placing an http call in the onCreationCompleted() method seems to be a good idea. But I tried that it gave an error that one of the UI component (e.g., an ActivityIndicator) was null. This could mean that the UI components were not ready to be used. Finally, I place the call right after app->setScene(root); call and it works. However, I wonder if this is the good choice. Thanks.
--tom