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

A mechanism for listening to lifecycle events in RNTA #275

Merged
merged 16 commits into from
Feb 5, 2021

Conversation

arazabishov
Copy link
Member

@arazabishov arazabishov commented Feb 2, 2021

Description

This PR adds a mechanism for listening lifecycle events such as application start, RN init, etc. It does it by looking-up methods in ReactPackage's provided by native modules using reflection.

The issue #145 is somewhat relevant, but doesn't address the exact problem.

Platforms affected

  • Android
  • iOS
  • macOS
  • Windows

Test plan

To test this change, you will need to link a native module that has a ReactPackage with one (or all) of the following methods:

public class LpcAndroidTestReactPackage implements ReactPackage, ReactTestAppLifecycleEvents {
    
    @Override
    public void onTestAppCreated() {
        System.out.println("onTestAppCreated()");
    }

    @Override
    public void onPreInitReactNativeInstance() {
        System.out.println("onPreInitReactNativeInstance()");
    }
    
    ...
}

@arazabishov arazabishov changed the title Call native package if lifecycle methods are present A mechanism for listening to lifecycle events in RNTA Feb 2, 2021
@arazabishov arazabishov force-pushed the arabisho/feature/lifecycle-events branch from dac613f to 32b6445 Compare February 2, 2021 09:09
plopfile.js Outdated Show resolved Hide resolved
@arazabishov arazabishov force-pushed the arabisho/feature/lifecycle-events branch from 85a87b9 to 469a76a Compare February 4, 2021 08:12
@arazabishov arazabishov marked this pull request as ready for review February 4, 2021 10:35
Copy link
Member

@tido64 tido64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine in general. I left a few questions because I have no idea how Android works.

ios/ReactTestApp/Public/ReactTestApp-DevSupport.h Outdated Show resolved Hide resolved
ios/ReactTestApp/ReactInstance.swift Outdated Show resolved Hide resolved
android/build.gradle Show resolved Hide resolved
example/android/build.gradle Show resolved Hide resolved
test-app.gradle Show resolved Hide resolved
Copy link
Member

@tido64 tido64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only some minor comments.

android/support/build.gradle Outdated Show resolved Hide resolved
Copy link
Member

@tido64 tido64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@arazabishov arazabishov added platform: Android This affects Android platform: iOS This affects iOS labels Feb 5, 2021
@arazabishov arazabishov self-assigned this Feb 5, 2021
@arazabishov arazabishov force-pushed the arabisho/feature/lifecycle-events branch from 97ab55c to ecc1828 Compare February 5, 2021 15:45
@arazabishov arazabishov merged commit df0953a into master Feb 5, 2021
@arazabishov arazabishov deleted the arabisho/feature/lifecycle-events branch February 5, 2021 16:08
@github-actions
Copy link

github-actions bot commented Feb 5, 2021

🎉 This PR is included in version 0.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Android This affects Android platform: iOS This affects iOS released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants