Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate declaration of method 'resolver:rejecter:' - Promises & Native Modules - RCT_REMAP_METHOD #9070

Closed
ferologics opened this issue Jul 28, 2016 · 6 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ferologics
Copy link

Error message: Duplicate declaration of method 'resolver:rejecter:'

RCT_REMAP_METHOD(get_data,
                 resolver:(RCTPromiseResolveBlock)resolve
                 rejecter:(RCTPromiseRejectBlock )reject)
{
  dispatch_group_wait(self.group, DISPATCH_TIME_FOREVER);
  [self compute_run_avg:^(NSMutableDictionary *result) {
    resolve(result);
  }];
}

RCT_REMAP_METHOD(send_count,
                 resolver:(RCTPromiseResolveBlock)resolve
                 rejecter:(RCTPromiseRejectBlock)reject)
{

}

Can I export only one method which uses promises?
Shouldn't the scope be limited to exported method?

if not

How can I reuse the method then?

thanks

@ide
Copy link
Contributor

ide commented Jul 28, 2016

Name the methods get_data_resolver:rejecter: and send_count_resolver:rejecter:. The remap macro only sets up an alias to the method name you give it.

@ide ide closed this as completed Jul 28, 2016
@ferologics
Copy link
Author

I tried that twice. Xcode gave me a C99 error.

After I quit Xcode and restarted my computer your solution works. 🌵

Either way, is is not really a nice solution long term. It works but, I should be able to use ANY name I want within that method as with parameters in any and every other method. that's how I feel intuitively.

thinking that is maybe nonsense because I'm unfamiliar with macros and how they work under the hood. More of a Swifter...

thanks for explaining 💯 👍 ❤️

@ide
Copy link
Contributor

ide commented Jul 28, 2016

You can use any name you want if you follow the rules of Objective-C. The macro defines an Objective-C method with the exact name that you give it.

@ferologics
Copy link
Author

What I mean is - if the exported method name is different from some other exported method name it should not matter whether the parameters are named same or not. In obj-c it won't complain if you have same parameter names in 2 distinct methods. But clearly that's not the case here 😅

Need to learn about macros... If you know of a resource that explains macros in a simple way I'd be delighted to read it. 🏆

as always, thanks for finding the time to read and reply 💯

@ide
Copy link
Contributor

ide commented Jul 29, 2016

I think you're misreading the macro. It's RCT_REMAP_METHOD(alias, method), not RCT_REMAP_METHOD(alias, parameters).

@xujialiang
Copy link

@ide thanks

facebook-github-bot pushed a commit that referenced this issue Apr 5, 2017
Summary:
The current docs (iOS) for promises make use of the `RCT_REMAP_METHOD` macro but it's not clear about the proper usage for the macro. Specifically, it points to a selector of `resolver:rejector:` and makes it seem like `findEvents` is assumed as both the alias and method name.

This has led to some confusion (#9070) on how to use `RCT_REMAP_METHOD`.

No tests needed since this is just a small docs update.
Closes #13302

Differential Revision: D4831755

Pulled By: javache

fbshipit-source-id: e842c16ade27088eafdac7509373cdf7780f9ece
thotegowda pushed a commit to thotegowda/react-native that referenced this issue May 7, 2017
Summary:
The current docs (iOS) for promises make use of the `RCT_REMAP_METHOD` macro but it's not clear about the proper usage for the macro. Specifically, it points to a selector of `resolver:rejector:` and makes it seem like `findEvents` is assumed as both the alias and method name.

This has led to some confusion (facebook#9070) on how to use `RCT_REMAP_METHOD`.

No tests needed since this is just a small docs update.
Closes facebook#13302

Differential Revision: D4831755

Pulled By: javache

fbshipit-source-id: e842c16ade27088eafdac7509373cdf7780f9ece
@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants