datso / react-native-pjsip

A PJSIP module for React Native.
http://datso.github.io/react-native-pjsip
GNU General Public License v3.0
272 stars 229 forks source link

Use RCT_REMAP_METHOD and get rid of Promise creating in JS files. #153

Open henrikbjorn opened 5 years ago

henrikbjorn commented 5 years ago

React Native exposes a RCT_REMAP_METHOD which will give a resolve and reject function as argument in the obj c code. This can be used to clean up the js code

RCT_REMAP_METHOD(getCodecs, getCodecsWithResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
    NSDictionary *codecs = [[PjSipEndpoint instance] getCodecs];

    resolve(codecs);
}
henrikbjorn commented 5 years ago
class Endpoint {
    getCodecs() {
      return NativeModules.PjSipModule.getCodecs()
    }
}