I'm trying to pass a callback method from one class to another when making a web request using `Comm.makeWebRequest`, but it doesn't seem to be working as expected.
Here's a simplified version of my setup:
class DataFetcher {
function fetchData(url as String, callback as (Method(responseCode as Lang.Number, data as Lang.Dictionary or Lang.String or PersistedContent.Iterator or Null) as Void)) as Void {
Comm.makeWebRequest(
url,
{},
{ :method => Comm.HTTP_REQUEST_METHOD_GET },
new Lang.Method($, :callback) // Attempting to pass the callback method reference
);
}
}And in another class:
class MainDelegate {
function onSelect() {
var fetcher = new DataFetcher();
fetcher.fetchData("https://example.com/api", method(:handleResponse));
}
function handleResponse(responseCode as Lang.Number, data as Lang.Dictionary or Lang.String or PersistedContent.Iterator or Null) as Void {
System.println("Response received: " + responseCode);
}
}The project builds successfully and the request is made, but when trying to invoke the callback, I get the following error:
Error: Symbol Not Found Error
Details: Failed invoking <symbol>
Stack:
What's the right way of going about this?