[TIMOB-18563] HAL: const JSObject cannot be used in concurrency::task().then
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | None |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2015-02-13T01:47:35.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Windows |
Labels | n/a |
Reporter | Gary Mathews |
Assignee | Ingo Muschenetz |
Created | 2015-02-12T23:41:23.000+0000 |
Updated | 2017-03-24T17:09:38.000+0000 |
Description
JSObject cannot be used in a concurrency::task().then callback without statically casting it back to a non-const.
*Examples*
JSValue GeolocationModule::forwardGeocoder(const std::string& address, JSObject callback) TITANIUM_NOEXCEPT
{
...
concurrency::create_task(httpClient->GetAsync(requestUri)).then([this, address, callback](HttpResponseMessage^ response) {
...
TITANIUM_ASSERT(callback.IsFunction());
// I would need to statically cast callback as a non-const
// JSObject to be able to use it
callback({forwardGeocodeResponse}, get_context().get_global_object());
});
return get_context().CreateUndefined();
}
You can use "&" to pass it as reference to lambda like "&callback" in this case.
Closing ticket as invalid.