react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Android] Use dependency injection to manage packages and modules

Open mickeyinfoshan opened this issue 11 years ago • 5 comments

Can we use a xml/json file to add packages and modules instead of coding in the MainActivity.java? Here's an example of the xml file:

<packages>
    <package class="com.foo.FooPackage.java" name="FooPackage">
        <module class="com.foo.FooModule.java" name="FooModule" />
        <module class="com.foo.AnotherModule.java" name="AnotherModule" />
        ...
    </package>
    <Package class="com.foo.AnotherPackage.java" name="AnotherPackage">
        ...
    </Package>
</packages>

mickeyinfoshan avatar Dec 01 '15 09:12 mickeyinfoshan

Hey mjhlybmwq, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If this is a feature request or a bug that you would like to be fixed by the team, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • If you don't know how to do something or not sure whether some behavior is expected or a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • We welcome clear issues and PRs that are ready for in-depth discussion; thank you for your contributions!

facebook-github-bot avatar Dec 01 '15 09:12 facebook-github-bot

Hey @mjhlybmwq , thanks for the report.

Why would you want to do that though? It means learning an entirely new thing to add packages. Current way is good enough IMO, and with react-native link being worked on, it's simple to use too.

satya164 avatar Dec 02 '15 03:12 satya164

@satya164 , thanks for your attention.

I think it's easier to learn for new-learners. Besides, managing packages by xml/json means it's possible to make a package manager, which makes it much easier to publish, install and uninstall a package.

mickeyinfoshan avatar Dec 03 '15 01:12 mickeyinfoshan

The XML looks easier but it's covering up a lot of details. With one or two lines of code you get a much more explicit view of what is happening, and if you want to understand more you can drill down into the Android SDK and read more code. The code is simple and significantly more transparent.

ide avatar Dec 03 '15 02:12 ide

@mjhlybmwq The XML syntax is a lot less flexible that what you'll be able to do with Java/Obj-C. For example, some packages might take some parameters in the constructor, etc. There is no way to accomodate all these with the XML syntax.

Also, if you are working with React Native, it goes a long way if you make yourself familiar with Java/Obj-C. Adding another abstraction doesn't really help.

satya164 avatar Dec 03 '15 03:12 satya164