HomePhabricator
Diffusion Comm ef97f1fc8578

[native] [31/40] RN 0.70: First commit for new AndroidLifecycle Expo module

Description

[native] [31/40] RN 0.70: First commit for new AndroidLifecycle Expo module

Summary:
We have an existing custom AndroidLifecycle React Native module, but it started having issues after the update: ENG-2484. I decided to migrate the module to an Expo module, which are newly supported as of Expo 47.

This diff contains basically an end-to-end "Hello World", mostly pulled from running npx create-expo-module expo-settings and filtering out just the pieces I wanted to keep.

Depends on D5925

Test Plan:
I patched the following into native/root.react.js:

import * as AndroidLifecycleModule from './lifecycle/lifecycle-module';

if (Platform.OS === 'android') {
  console.log(`androidLifecycle.PI: ${AndroidLifecycleModule.PI ?? 'null or undefined'}`);
  console.log(`androidLifecycle.hello(): ${AndroidLifecycleModule.hello() ?? 'null or undefined'}`);
  (async () => {
    AndroidLifecycleModule.addChangeListener(({ value }) => { console.log(`onChange ${value}`) });
    await AndroidLifecycleModule.setValueAsync('testing!!');
    console.log('done testing');
  })();
}

It resulted in the following output:

LOG  androidLifecycle.PI: 3.141592653589793
LOG  androidLifecycle.hello(): Hello world! đŸ‘‹
LOG  onChange testing!!
LOG  done testing

Reviewers: bartek!, tomek

Subscribers: atul

Differential Revision: https://phab.comm.dev/D5932