Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How I Lost 30 Pounds with Xamarin and Couchbase Lite: Couchbase Connect 2015

1,772 views

Published on

In this session we’ll see how developing mobile apps with Couchbase Lite and Xamarin is a breeze, allowing you to develop mobile applications for many types of platforms...quickly. We’ll cover everything from adding Couchbase Lite to a Xamarin application, to working with the API for local storage, and syncing via the Sync Gateway. You’ll walk away with all the information you need to get started using Couchbase Lite in your own Xamarin apps.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

How I Lost 30 Pounds with Xamarin and Couchbase Lite: Couchbase Connect 2015

  1. 1. Couchbase Lite & Xamarin How I lost 30 pounds with Couchbase Lite Mike Bluestein @mikebluestein mike.bluestein@thinkaheadsoftware.com
  2. 2. “Mike, how did you lose all this weight?” “The same way any normal person loses weight. I started using Couchbase Lite to get an easy abstraction around offline data access in mobile apps, while gaining nearly automatic syncing with the server.”
  3. 3. What is Xamarin? • Platform to develop native iOS and Android apps in C# or F#
  4. 4. What is Xamarin? • Xamarin.iOS (formerly MonoTouch) • Xamarin.Android (formerly Mono for Android) • Various other products and features • Xamarin.Mac, Test Cloud, Xamarin Insights, Xamarin Forms, Xamarin Profiler, Sketches, …
  5. 5. What is Couchbase Lite? • Provides document based data access on iOS, Android and Windows platforms
  6. 6. What is Couchbase Lite? • Offline • Indexing via MapReduce over views • Syncing with Couchbase servers via Sync Gateway • .NET API distributed via NuGet
  7. 7. Couchbase Lite + Xamarin • Document based data access with offline support and syncing from cross platform, shared code
  8. 8. Couchbase Lite API
  9. 9. Manager • Manages access to Couchbase Lite database • Available via Manager.SharedInstance singleton Manager.SharedInstance.GetDatabase ("mydatabase");
  10. 10. Database • Encapsulates the Couchbase Lite database • API to access documents (CRUD APIs)
  11. 11. Document • Represents a Couchbase Lite document • Allows saving and retrieving data via a Dictionary
  12. 12. CRUD Operations • Create • Read • Update • Delete db.CreateDocument (); db.GetDocument (docID); doc.PutProperties (props); doc.Delete ();
  13. 13. Attachments • Attachments encapsulate binary data • Allow storage alongside document • Represented with MIME type • Storage is smart
  14. 14. Queries
  15. 15. Querying Approach Create a Query Run the QueryCreate a View
  16. 16. View • Index documents • MapReduce var myView = db.GetView ("myView");
 myView.SetMap ((doc, emit) => emit (…);
  17. 17. Query • Create Query from a View • Supports async • Return QueryEnumerator var orderedQuery = myView.CreateQuery (); var results = await orderedQuery.RunAsync ();
  18. 18. Live Query • Created from a Query • Listen for Changes • Changed Event var liveQuery = myView.CreateQuery().ToLiveQuery();
 liveQuery.Changed += (object sender, QueryChangeEventArgs e) => {
 var rows = e.Rows; // ...
 };
 liveQuery.Start ();
  19. 19. Syncing
  20. 20. Sync Gateway • Replicates data between Couchbase Lite and Couchbase server • Pull and Push replication via Couchbase Lite API • In memory server for development Replication pull = db.CreatePullReplication (gatewayUri);
 Replication push = db.CreatePushReplication (gatewayUri); // ... pull.Start ();
 push.Start ();
  21. 21. Demo
  22. 22. Thanks! Mike Bluestein @mikebluestein mike.bluestein@thinkaheadsoftware.com

×