Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Crafting Reactive Apps with Realm Mobile Platform

Crafting Reactive Apps with Realm Mobile Platform

Realm is a popular database for mobile used already in thousands of apps in the app stores and deployed on over a billion devices. This talk will show you how you can craft reactive applications, especially if you embrace persistence and state as a central part of your application architecture, by using the unique features of this database. Beyond that it will explore how this can be extended on multiple devices and the server-side with the recently launched Realm Mobile Platform and its synchronization capabilities.

Avatar for Marius Rackwitz

Marius Rackwitz

October 22, 2016
Tweet

More Decks by Marius Rackwitz

Other Decks in Programming

Transcript

  1. mr@realm.io // Person.swift import UIKit import RealmSwift class Person: Object

    { dynamic var name = "" dynamic var age = 0 let children = List<Person>() let parents = LinkingObjects(fromType: Person.self, property: "children") } let person = Person() person.name = "Craig" person.age = 47 let realm = try! Realm() try! realm.write { realm.add(person) } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 realmSampleApp Generic iOS Device
  2. mr@realm.io // Person.swift import UIKit import RealmSwift class Person: Object

    { dynamic var name = "" dynamic var age = 0 let children = List<Person>() let parents = LinkingObjects(fromType: Person.self, property: "children") } let person = Person() person.name = "Craig" person.age = 47 let realm = try! Realm() try! realm.write { realm.add(person) } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 realmSampleApp Generic iOS Device // Person.swift import UIKit import RealmSwift class Person: Object { dynamic var name = "" dynamic var age = 0 let children = List<Person>() let parents = LinkingObjects(fromType: Person.self, property: "children") } let person = Person() person.name = "Craig" person.age = 47 let realm = try! Realm() try! realm.write { realm.add(person) } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 realmSampleApp Generic iOS Device
  3. mr@realm.io Modi"cations only in explicit
 write transactions. let person =

    Person() person.name = "Craig" person.age = 47 let realm = try! Realm() try! realm.write { realm.add(person) } try! realm.write { person.age = 48 } 1 2 3 4 5 6 7 8 9 10 11 12 13 realmSampleApp Generic iOS Device
  4. Built-in Noti"cations • File-wide Observation • Fine-grained Noti!cations on Collections

    • Observe Individual Object Properties mr@realm.io Not all of these features are available yet on all platforms.
  5. mr@realm.io Swift class Account { dynamic var amount: Money dynamic

    var currency: Currency } JSON { “amount”: 1000.45, “currency”: “USD” } POST %7B%E2%80%9Camount%E2 %80%9D%3A+1000.45%2C+ %E2%80%9Ccurrency%E2%80 %9D%3A+%E2%80%9CUSD… Dictionary [ “amount”: Double, “currency”: String ] And decode that back on the server…
  6. Coupon DC9WP Coupon DC9WP coupon.code = DC9WP coupon.isValid = true

    1 2 3 validate() Event Handling mr@realm.io
  7. Built-in Noti"cations • Observe All Realms • File-wide Observation •

    Fine-grained Noti!cations on Collections • Observe Individual Object Properties mr@realm.io
  8. Thanks for your attention! 
 Follow me on Twitter /

    GitHub
 @mrackwitz Get in touch to learn more:
 mr@realm.io mr@realm.io