Skip to content

Question about Native Modules #15586

@sm2017

Description

@sm2017

According to https://facebook.github.io/react-native/docs/native-modules-android.html native android modules extends ReactContextBaseJavaModule , Is the module singleton?

If I have the following method

@ReactMethod 
public void testMethod(String message, Promise promise) { 
    this.promise = promise;
}

and

MyModule.testMethod('A').then(function(result){
    console.log(result);
});

MyModule.testMethod('B').then(function(result){
    console.log(result);
});

MyModule.testMethod('C').then(function(result){
    console.log(result);
});

What happens exactly? is MyModule.testMethod('C') overwrite this.promise (the module is singleton ) OR each time the new instance of module is created and promise is a property and isolated?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ran CommandsOne of our bots successfully processed a command.Resolution: For Stack OverflowA question for Stack Overflow. Applying this label will cause issue to be closed.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions