Skip to content

Prevent emitting log events without listeners - #1108

Merged
mattijsf merged 1 commit into
masterfrom
mattijsf/logger-fix
Nov 17, 2020
Merged

Prevent emitting log events without listeners#1108
mattijsf merged 1 commit into
masterfrom
mattijsf/logger-fix

Conversation

@mattijsf

Copy link
Copy Markdown
Member

Added check before emitting LogEvent messages via RCTEventEmitter.

On iOS each RCTEventEmitter module needs to track whether or not there are observers before sending events. Otherwise when events are emitted without observers a (console) warning is triggered by react-native, in this case:

Sending LogEvent with no listeners registered.

In practice I experienced Mapbox sending out messages after unmount causing the above warning.

Similar to https://github.com/react-native-mapbox-gl/maps/blob/f2eb9d7bb55cb3227b2ccc432de11e13246c689f/ios/RCTMGL/RCTMGLLocationModule.m#L85-L96

@mattijsf
mattijsf requested a review from mfazekas November 17, 2020 08:18
@mattijsf
mattijsf merged commit d6c8a93 into master Nov 17, 2020
@ferdicus
ferdicus deleted the mattijsf/logger-fix branch August 20, 2021 10:18
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.

2 participants