Skip to content
Discussion options

You must be logged in to vote

Hi @alexphl, as you mentioned, runOnRuntimeAsync is not yet implemented.

If you want to return a value with a promise, the best approach at the moment is to manually make a promise, i.e.:

import {
  createWorkletRuntime,
  scheduleOnRuntime,
  scheduleOnRN,
} from 'react-native-worklets';

const workletRuntime = createWorkletRuntime({ name: 'MyRuntime' });

const promise = new Promise<string>((resolve) => {
  scheduleOnRuntime(workletRuntime, () => {
    'worklet';
    console.log('Resolving promise on worklet runtime');
    scheduleOnRN(resolve, 'Promise resolved on worklet runtime');
  });
});

promise
  .then((message) => {
    console.log(message);
  })
  .catch(() => {});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by alexphl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants