With React Native it’s not all sugar and spice(blog.addjam.com) |
With React Native it’s not all sugar and spice(blog.addjam.com) |
I use react-native solely for the UI which I update, redux-style, with a state-tree. The state and all it's transition and event-handling is done in Kotlin/Java. I've written a small helper that generates kotlin-Interfaces from the react/jsx-files and automatically connects everything.
This way I have react's HotReload and the other benefits for UI-design and a proper typed language and IDE for networking and everything else. Including compile-time checking of events and properties of the UI.
Plus: Kotlin can compile to JavaScript, so if I ever want to port the whole thing to iOS, i just have to switch out a few APIs.
Regarding bansa: Sounds nice, but I've never seen the benefit of using a library for state and state-reduction. You can implement and customise for yourself in less than 50 lines. (I don't use the redux library on the web either)
The only thing I would like is being able to reuse data-structures of react-native, so they won't get serialized all the time.
Thanks for the tips, though!
I have a Controller that takes UIEvents and NetworkEvents from a BlockingQueue (CSP). The state reduces everything. Kotlin's "when" constructs are extremely convenient here, but want to make sure I'm not going to far into the functional direction, if you get what I mean.
The state is completely serialisable (in fact gets serialised to and from JSON in onPause/onResume).
I'm doing networking declaratively as well, a serialisable request-description is put into the state and it's the "NetworkManager"'s job to figure out which requests to start or stop.
Kotlin's delegated property are also awesome, because I can mix and match functions and variables.
/* show loading animation */
override val isLoading by stateFn {
it.runningRequests.any { it is LoginReq }
}javascript:(function (){var x = document.getElementsByTagName("img");for (i = 0; i < x.length; i++){x[i].setAttribute("src","");}}());
I really want to read the article but it's a struggle with the gifs
Regarding code organization, I found redux to be a well established tool with clear patterns.
Some have their own way to hang together a project. Much of the React ecosystem is not so opinionated. A lot of JavaScript out there exists in codebases in a variety of languages and frameworks—Rails, PHP, Node... you name it. Modern JavaScript build tools reflect the need for script sources and build targets to reside anywhere based on what the site JavaScript is being used in. I'd say this historical influence is showing in React Native.
However, I also think this makes sense for React Native. It's possible it's getting introduced into apps which already have conventions based on the platform the app is for and the team writing it. It might not make sense for React Native to come up with a new set of conventions when you're working with multiple platforms and existing codebases.
> But the real value is in sharing code, maintaining projects and on boarding new members to a project team. [...] We’ve spent a long time viewing projects on GitHub and picking and choosing what we feel is the best way a project should be structured.
Conventions—whether they're forced on you by the framework authors or developed by the community—are still part of learning a framework and working with it for the first time. I'd say what author came away with here is even more important than just having some convention—they landed with something they really think is best for their projects! The real cost here is that onboarding developers will also include time for them to get familiar with this project structure, but is that really so much to ask?
It's not like those IDEs can't be configured to work with the raw tools.
http://www.sheshbabu.com/posts/guidelines-to-choose-a-javasc...
I agree with the instability though, nothing for someone afraid of rumbling around in the RN source code to solve things like this https://github.com/facebook/react-native/issues/7720
Sure there will be growing pains starting out, but the benefits that are coming from this new direction are, in my opinion, worth all the effort. I've written several apps utilizing React Native now, and love the efficiency boost it gives me.
Deco IDE
[0]http://j2objc.org/ [1]http://www.gwtproject.org/ [2]http://www.jsweet.org/
Directly available in iOS, Android, WP, Tizen, Ubuntu SDKs.
The only major problem is the way Google disregards their NDK stack, while Microsoft and NVidia engineers are able to do what Google PhDs are not.
When doing more app like coding, following MVVM patterns with the view written in the platform language.
On iOS you can use Objective-C++, on WP and UWP C++/CX.
Android is the worst because Google keeps the NDK at an arm's length, but projects like Djinni and SafeJNI help.
If you don't bother to provide a native experience, but still enjoy the portability of C++'s code, there is always Qt and QML.