-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Android] AppState #5152
[Android] AppState #5152
Conversation
By analyzing the blame information on this pull request, we identified @vjeux, @zjj010104 and @mkonicek to be potential reviewers. |
We have this module internally and want to open source it, let me compare the implementations. |
Thanks for working on this! |
No problem, thanks for quick response. If I can help you somehow to deliver it faster just let me know. |
I think we should still keep Here's the internal module: If you can make |
Sorry for the delay on this! |
I'll update pr in few days. Could you please don't release AppStateAndroid? I want to make it same for both platforms as you said. |
7820338
to
bf49bde
Compare
@skv-headless updated the pull request. |
|
||
var React = require('react-native'); | ||
var { | ||
AppState, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
property AppState
Property not found in Object.create
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can ignore this lint warning.
bf49bde
to
5d3a887
Compare
@skv-headless updated the pull request. |
@mkonicek could you please review? |
|
||
var React = require('react-native'); | ||
var { | ||
AppState, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
property AppState
Property not found in Object.create
Since we're introducing a new API, we should use promises instead of callbacks. Refer #4971 |
@Override | ||
public void onHostPause() { | ||
mAppState = "background"; | ||
getReactApplicationContext().getJSModule(RCTDeviceEventEmitter.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also have a method sendAppStateEvent
?
private void sendAppStateEvent(WritableMap appState) {
getReactApplicationContext().getJSModule(RCTDeviceEventEmitter.class)
.emit("appStateDidChange", appState);
}
Thanks again for working on it! I'm a bit swamped but will try to review tomorrow. |
5d3a887
to
1d894ae
Compare
@skv-headless updated the pull request. |
|
||
var React = require('react-native'); | ||
var { | ||
AppState, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
property AppState
Property not found in Object.create
Is |
public class AppStateModule extends ReactContextBaseJavaModule | ||
implements LifecycleEventListener { | ||
|
||
private String mAppState = "active"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default state should be "uninitialized" as per the internal module: https://gist.github.com/mkonicek/039f35748c0a073dd1b5
What's the rationale for setting it to "active"?
|
||
@Override | ||
public void onHostResume() { | ||
mAppState = "active"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Please use constants like in https://gist.github.com/mkonicek/039f35748c0a073dd1b5
Getting close! Very excited! |
AppState.js is a copy of AppStateIOS.ios.js |
Thanks! I guessed that was the case. |
@mkonicek agree with all notes, thank you for review. I'll try to fix tomorrow. |
If that's the case, can you also get rid of |
If the APIs are exactly the same, maybe we can just require the |
I like the idea of making |
@skv-headless Cool! Once you address the comments I think we can merge this. |
1d894ae
to
617a1b3
Compare
@skv-headless updated the pull request. |
@mkonicek updated.
|
|
||
var React = require('react-native'); | ||
var { | ||
AppState, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
property AppState
Property not found in Object.create
Awesome! @facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/581762778640408/int_phab to review. |
c2d75d7
Summary: Closes #5152 Reviewed By: svcscm Differential Revision: D2850250 Pulled By: mkonicek fb-gh-sync-id: 0b5063fa7121d4e304a70da8573c9ba1d05a757c
guy can you tell me what is the difference between AppStateIOS and AppState. |
No description provided.