Skip to content

Use promises on NativeMethodsMixin instead of callbacks #20579

Closed
@jgfidelis

Description

@jgfidelis

Today we use NativeMethodsMixin likes this:

NativeMethodsMixin.measure.call(ref, callback)

We could do something like:

const NativeMethodsMixinAsPromise = (ref) => {
  return new Promise((resolve, reject) => {
    try {
      NativeMethodsMixin.measure.call(ref, (x, y, width, height) => resolve(x, y, width, height))
    } catch (err) {
      reject(err);
    }
  });
}

Something along these lines, so we can use async and await and have a more fluid code.

Can't we make it like this on react-native core?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ran CommandsOne of our bots successfully processed a command.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