I want to make multiple WebRequests with different URLs in the WebRequest SDK sample.
In the WebRequest SDK sample I have duplicated the WebRequestDelegate.mc file and renamed it WebRequestDelegate2.mc.
In the new WebRequestDelegate2.mc file I have renamed the onReceive function to onReceive2 and changed the end of makeRequest() function to method(:onReceive2).
In both WebRequestDelegate.mc and WebRequestDelegate2.mc added makeRequest(); to initialize function so it makes request at start without pressing a button.
In the WebRequestView.mc file I have duplicated the onReceive function and renamed it to onReceive2.
In the WebRequestApp.mc file I have modified the getInitialView function to this:
//! Return the initial view for the app
//! @return Array Pair [View, Delegate]
public function getInitialView() as Array<Views or InputDelegates>? {
var view = new $.WebRequestView();
var delegate = new $.WebRequestDelegate(view.method(:onReceive));
var delegate2 = new $.WebRequestDelegate2(view.method(:onReceive2));
return [view, delegate] as Array<Views or InputDelegates>;
}
In the WebRequestView.mc I have two string variables to display the content which is received in onReceive and onReceive2 functions in WebRequestView.mc.
So far everything works and the data loads correctly on startup.
But if I press the menu or select button it seems it only runs the onMenu() and onSelect() function in WebRequestDelegate.mc file and not also in WebRequestDelegate2.mc.
Did I make this correctly or is there a much better way to make multiple WebRequests with different URLs in the WebRequest SDK sample?