Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is an issue when developing React Native apps that have
deepwall-react-native-sdk
package installed.Imagine a RN app that has Deepwall properly set up, and has a listener for a Deepwall event as such:
What a developer would see in their terminal when the app is starting is a string saying
paywall opened
. When the developer makes a change on the app's Javascript codes and saves the file, the app reloads to reflect the changes. What that developer now sees in their terminal when the app is reloading is two new strings sayingpaywall opened
.The reason the event listeners getting called twice is because on the reload action, the underlying native app does not actually restart. Only the Javascript part restarts. Every time JS part restarts, it calls the initDeepwall() function to start Deepwall's functionalities, but on recurring reloads of the JS part the Deepwall is already initiated. See the simple scenario below for alternative explanation.
This PR introduces a simple boolean flag and a guard check to fix that problem.