Skip to content

Adjust AppState to match 0.65 API#2129

Closed
netshade wants to merge 5 commits intonecolas:masterfrom
connectedbits:appstate-mirror-0.65-api
Closed

Adjust AppState to match 0.65 API#2129
netshade wants to merge 5 commits intonecolas:masterfrom
connectedbits:appstate-mirror-0.65-api

Conversation

@netshade
Copy link
Contributor

In 0.65, AppState has been changed to emit an EmitterSubscription when calling .add; this is in line w/ the expectation that you should no longer call removeEventListener on AppState, but instead call .remove on the returned subscription. This PR changes AppState such that it uses the internal _EventEmitter object to mirror how 0.65+ AppState should behave, and allow callers to unsubscribe from the emitter using the .remove method.

In doing so, this changes the implementation such that document should only ever have one and only one event listener to app viability changes; that event listener does the work of dispatching to the internal EventEmitter object, which dispatches to any N application level event listeners that are waiting for AppState changes.

Thanks for any review / criticism, not sure if that implementation change is the right one or captured what changed correctly. Also feel slightly sketchy with regards to what I did in the tests, so happy for any opinion there.

@necolas necolas added this to the 0.17.x milestone Sep 21, 2021
@necolas necolas closed this in 1266427 Sep 29, 2021
@siarheipashkevich
Copy link

But it's a breaking changes for react-native older than 0.65.*

rnike pushed a commit to VeryBuy/react-native-web that referenced this pull request Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants