![]() ![]() We’ve were able to use shared C# code for our new native components in the app, and development and testing became quicker and less frustrating. So, How’s the Project Doing?Īfter switching to Xamarin, the application’s performance problems disappeared. There is a sample repo showing how to make this interoperability happen. There is quite a bit of glue needed to make this setup work. ![]() later on, destroy the subscription when you're done This._positionSub = Xamarin.subscribe('ExampleServiceObject.OnPositionChanged', Var p1Point = Xamarin.call('ExampleServiceObject.GetCoord', "player1") Import Xamarin from 'my-project/utils/xamarin-interop' This will automatically be serailized back as JSON Public async Task GetCoord(JToken someArg) Here are a couple quick examples and all the code required to set it up on your own Xamarin project. Once set up, the interfaces to execute native code and subscribe to observables from JavaScript are quite nice. It can still use our Ember.js app with very few changes to our JS/HTML/CSS.It gets access to C# and its features (Rx.net, async/await, type checking/inference).It’s DRY it implements most logic in C# with minimal amounts of native code specific to Android or iOS.It’s performant it compiles down to native, supports multiple threads.Using Xamarin with the HybridWebView addressed all of our problems with Cordova: Any native pieces are mostly bolt-ons that need to be completely implemented in each of the native platforms you wish to support. Because Cordova is so browser-centric, JavaScript and its one thread are your only option for computation. Even if we used an SQLite plugin to offload the data storage, processing became unbearably slow. We needed to download, process, and store most of our users’ data locally on the device. In our app, we had to support full offline functionality. The main vehicle for any app logic is the JavaScript run-time in the native web view. Cordova takes a very WebView-centric approach. Pain Train Arrives at the StationĬordova does a decent job of building apps for both Android and iOS, but there are still a lot of rough edges. To avoid a major rewrite and overhaul of the design, and because we’d worked with Cordova in the past, we went with it. ![]() And our client had an existing Cordova application. So how did we get to that point? Why Cordova? Well, Cordova is a cross-platform framework for building mobile web apps hosted in a native shell. As the project progressed, it became clear that this tech stack was not going to hold up. Offline support meant downloading most of our users’ data, processing it, and storing it-all while keeping the UI responsive using the single Javascript thread. That would usually be pretty normal, but in this case, it was an Ember app running in Cordova utilizing massive amounts of offline support. At the tail end of last year, my team was working on an Ember.js app. ![]()
0 Comments
Leave a Reply. |