I am trying to implement Amazon FireTV's code via a Bridge from react-native. My goal is to send a signal to the remote player, then resolve the RCTPromiseResolveBlock so that in my javascript I can await the function.
@objc func fling(_ options: NSDictionary, _ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
let player = getDeviceFromUuid(uuid:uuid) // instance of RemoteMediaPlayer
// ... more code
let bftask = player?.setMediaSourceToURL(
url,
metaData:metaData,
autoPlay:true,
andPlayInBackground:false)
bftask?.continue({ (task:BFTask) -> Void in
if task.error != nil {
reject() // <-- These are "non-escaping parameters captured in an escaping closure"
} else {
resolve() // <--
}
})
The above code throws Escaping closure captures non-escaping parameter
. How do I allow reject & resolve to be available in the closure? Or more broadly, how do I execute the asynchronous request setMediaSourceToURL
, wait for it's completion, and then resolve the promise block?
For reference, BFTask is an artifact of https://github.com/facebookarchive/Bolts-ObjC . It's interface suggests the following:
I look to you, wizards of the IOS world.