-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Add an 'Experiments' class to enable/disable experiments. #5446
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
Conversation
By analyzing the blame information on this pull request, we identified @none to be a potential reviewer. |
A couple of thoughts -- is there a way to scope experiments to the ReactInstanceManager object? Ex: this allows for separate ReactInstanceManagers to run different experiments. Also how about using strings or something more self-descriptive than ints for the experiment IDs so that if we persist them on disk there isn't the risk of someone deleting an experiment with ID = 0, and then later adding a new experiment with ID = 0 and confusing the two? |
Thanks for the inputs @ide
Maybe we can use namespaces? Right now we don't really have many experiments. But if we have in future, the
Yeah. makes sense. I'll change it to use strings :) |
@satya164 updated the pull request. |
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class Experiments { |
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.
Add Javadoc explaining what the reason this class exist is please.
Will add the docs in a bit. |
@mkonicek Enabling it should add |
@satya164 updated the pull request. |
@mkonicek Done. |
|
||
|
||
/** | ||
* This class exposes a way to enable/disable exprimental features in React Native. |
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: typo in exprimental
small nit: Could say "exposes a way for app developers to enable/disable..." or similar - to make it clear this is public API intended to be called by the apps, not just by the framework.
Some small nits and let's shipit :) |
Wow! That's a ton of typos! Fixed :) |
@satya164 updated the pull request. |
@satya164 updated the pull request. |
👍 @facebook-github-bot shipit |
Good idea with the strings @ide! |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/215773062097347/int_phab to review. |
Import failed because of an internal Buck file. |
The Buck file was actually useful at highlighting that this way we have a circular dependency between Would it be cleaner to have a method on
Also realized we might have a problem with introducing the Also, does the hot module reloading work on Android in 0.19.0-rc if you enable the experiment and enable it in the menu? I tried it by changing the render function in my We're introducing the How about the following? Ship HMR as a menu option for everyone once it works well on Android. For now, remove the |
That was my initial idea actually. But then I thought that it's probably easier not to tie it to
As per my thinking, the One way to do it will be to change the method name to
No it doesn't work yet. But @martinbigio told he had made some progress on Android front also :)
My thinking was that we could use it for enabling more experimental features in future, which are work in a progress and needs testing from the community. The main idea behind this new class is for people who want to test new experimental features can test them easily. Changing the source code of React to enable a feature is troublesome for testing, because we'll be installing from master a lot as we're testing, and it'll be overwritten everytime. That's why I wanted a way to enable it in the app's code.
It prolly makes more sense to put this class under Thanks for all the points. I understand the problems arising due to this. If you wanna remove it, I'm fine with it. We can think of a better way of doing this in the future. :D |
Yup, making it static is easier but introduces those circular dependencies between packages which are usually a code smell.
Right, but anyone who has enabled some experiments in the past will see their code break every time we remove an experiment. We could get around this by not using those Java constants but just strings.
If it doesn't work at all in 0.19, why let people enable it via
No problem! I should have thought about it more in details when you messaged me first but I'm sometimes a bit overwhelmed, sorry! |
Yeah. I understand. We need to give this some thought, on how to enable features for testing purposes only in future.
No issues. I should also have thought about this a bit more. @mkonicek should I send a PR commenting out the menu item? |
Yes please let's comment out the menu item for now. Thank you and thanks for understanding! |
To enable an experiment (say HMR),
To check if an experiment is enabled,
See #5339
Test plan - In a fresh project "Enable Hot Module Replacement" shouldn't exist in dev menu. It should appear after enabling HMR in
MainActivity
'sonCreate
.