introduction to realm mobile platform
TRANSCRIPT
![Page 1: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/1.jpg)
IntroducingRealm Mobile Platform
Build Better Apps Faster!
.
Christian Melchior@chrmelchior
![Page 2: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/2.jpg)
About Realm• Headquartered in San Francisco, with engineering office
in Copenhagen • ~50 employees • Series B startup, $29M raised
![Page 3: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/3.jpg)
Realm Mobile Database• On-device cross-platform object database • Launched July 2014 • Developed in the open, fully open source • 16K+ GitHub stars, 100K+ active developers
![Page 4: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/4.jpg)
Developers Love Realm for Power, Simplicity, Ease of Use
![Page 5: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/5.jpg)
Apps of Every Type, 1.000.000.000+ installs
![Page 6: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/6.jpg)
Realm Mobile Platform
![Page 7: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/7.jpg)
Users Expect More of Apps Today• Offline first: They need apps that work well offline and when network
connections are intermittent
• Reactive: They expect apps that are highly responsive, with all changes immediately reflected in the UI
• Real-time: They expect every user and device to stay in sync with each other in real-time
• Collaborative: They want highly collaborative features and experiences within their apps
• Seamless: They expect to be able to move seamlessly from device to device
![Page 8: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/8.jpg)
The Apps You Want To Make
![Page 9: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/9.jpg)
The AppYou Can MakePrice
Synchronisation is HARD
Deadlines
Crossplatform concerns
Backend team to busy
![Page 10: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/10.jpg)
The Realm Mobile Platform
Realm Mobile DatabaseRealm Object Server
Real-time data sync
![Page 12: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/12.jpg)
Realm Mobile
Database
Real-time Sync
Realm Object Server
SDKSDKSDK
Sync Engine Dashboard Auth
System
Encryption Layer
What is it?
Access Control Full DB access
Data connectorsObject Store
SD
SDK
SDK
Enterprise Feature
Event Framework
![Page 13: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/13.jpg)
Developer priorities• Time-to-market: Your team need to be able to deliver quality apps
quickly and on time
• Ability: With high user expectations, the team need the ability to easily add advanced features like data sync, messaging and collaboration.
• Cross-platform: To reach the full audience, you need to be able to deliver apps for both iOS and Android
• Standardize: To manage all the apps and reduce complexity, you want to standardize on a single platform
![Page 15: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/15.jpg)
The Reality With REST
![Page 16: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/16.jpg)
REST is brittle and cumbersome in a mobile world• What happens when there is no connectivity?
• Queueing? • Persistence?
• What about connectivity being lost during requests? • Tokens? Do they have to be persisted in app? • State-full services?
• Resource intensive • Need for multiple REST calls. High latency cost • Often incurs duplication of data • JSON parsing is expensive
![Page 17: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/17.jpg)
Delivers Key Mobile Solutions• Eliminates network challenges • Simplifies data architecture • Unlocks existing infrastructure
![Page 18: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/18.jpg)
SDK1 2
• Offline-first • Full database on the device
• Queries run locally • Writes apply immediately
• Reactive architecture keeps UI up-to-date • Automatic sync happens in the background • Resilient to any network conditions
Eliminate Network Challenges
![Page 19: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/19.jpg)
Objects as API’s
MobileServer
Realtime data sync
BuyObjectShoppingCart: →Status: nilOrderInfo: nil
![Page 20: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/20.jpg)
Objects as API’s
MobileServer
Realtime data sync
BuyObjectShoppingCart: →Status: nilOrderInfo: nil
BuyObjectShoppingCart: →Status: nilOrderInfo: nil
![Page 21: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/21.jpg)
Objects as API’s
MobileServer
Realtime data sync
BuyObjectShoppingCart: →Status: nilOrderInfo: nil
BuyObjectShoppingCart: →Status: nilOrderInfo: nil
![Page 22: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/22.jpg)
Objects as API’s
MobileServer
Realtime data sync
BuyObjectShoppingCart: →Status: nilOrderInfo: nil
BuyObjectShoppingCart: →Status: nilOrderInfo: nil
![Page 23: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/23.jpg)
Objects as API’s
MobileServer
Realtime data sync
BuyObjectShoppingCart: →Status: “processing”OrderInfo: nil
BuyObjectShoppingCart: →Status: “processing”OrderInfo: nil
![Page 24: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/24.jpg)
Objects as API’s
MobileServer
BuyObjectShoppingCart: →Status: “done”OrderInfo: → Realtime data sync
![Page 25: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/25.jpg)
Objects as API’s
MobileServer
Realtime data sync
BuyObjectShoppingCart: →Status: “done”OrderInfo: →
BuyObjectShoppingCart: →Status: “done”OrderInfo: →
![Page 26: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/26.jpg)
Delivers Key Mobile Solutions• Eliminates network challenges • Simplifies data architecture • Unlocks existing infrastructure
![Page 27: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/27.jpg)
Typical Application Data Flow
Native object
JSON
Native object
SQL
Native object
JSON
Native object
SQLite SQLite
![Page 28: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/28.jpg)
• It’s just objectson the device and on the server
• Objects are live,they update—automatically and immediately—in response to changes
• Not an ORM,the database is the data model
• Easier for developers to build, change, maintain
• Reduce code complexityvia unified data format; cross-platform
• Encrypted at rest & transitObjects all the way down
Simplify Data Architecture
![Page 29: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/29.jpg)
Delivers Key Mobile Solutions• Eliminates network challenges • Simplifies data architecture • Unlocks existing infrastructure
![Page 30: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/30.jpg)
Legacy Systems Hold Back Mobile
XML JSONRESTSOAP
/facilities /departments{"facility": "west-1A", "departments": [ {"type": "manufacturing"}, {"type": "operations"}]}
<?xml version="1.0" encoding="UTF-8" ?><root> <department>manufacturing</department> <facilities>west-1A</facilities></root>
![Page 31: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/31.jpg)
Unlock Existing Infrastructure
DC9WP
Coupon:
Coupon:
DC9WP
coupon.code = DC9WP
coupon.isValid = true
1
2
3
• Bridge legacy APIs • Shift complexity to backend
• Node.js SDK • Identical object interface • Full database capabilities • Apply changes to push data
• Event framework • Listen and respond to changes from clients • Pass along data to other systems or databases
• Supports custom authentication
![Page 32: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/32.jpg)
The code centric view
![Page 33: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/33.jpg)
Realm is an object database
![Page 34: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/34.jpg)
Create native objects that map directly to the database.
// Define you model class by extending RealmObject public class Dog extends RealmObject { public String name; // fields can also be private of course public int age = 1; // default values }
public class Person extends RealmObject { @PrimaryKey public long id; public String name; // support for custom logic in accessors public RealmList<Dog> dogs; // declare one-to-many relationships }
![Page 35: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/35.jpg)
Perform complex queries across your object graph
RealmResults<User> result2 = realm.where(User.class) .equalTo("name", "John") .or() .equalTo("name", "Peter") .findAll();
RealmResults<User> result = realm.where(User.class).findAll(); result = result.sort("age"); // Sort ascending result = result.sort("age", Sort.DESCENDING);
![Page 36: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/36.jpg)
All changes occur in transactions offering ACID compliance
// Obtain a Realm instance Realm realm = Realm.getDefaultInstance();
realm.beginTransaction(); Book cheeseBook = realm.createObject(Book.class); cheeseBook.title = "Gouda Recipes"; cheeseBook.id = 1; realm.commitTransaction();
![Page 37: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/37.jpg)
But Realm objects have a special capability…
![Page 38: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/38.jpg)
Realm objects live-update in response to changes
RealmResults<Dog> puppies = realm.where(Dog.class).lessThan("age", 2); puppies.length(); // => 0
realm.beginTransaction(); Dog myDog = realm.createObject(Dog.class); myDog.name = "Rex"; myDog.age = 1; realm.commitTransaction();
puppies.length(); // => 1
![Page 39: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/39.jpg)
Realm is a live object databaseRealm is an object database
![Page 40: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/40.jpg)
Listen for live object changes to simplify your architecture RealmResults<Person> persons = realm.where(Person.class).findAll(); persons.addChangeListener(new RealmChangeListener() { @Override public void onChange(RealmResults<Person> change) { // ... do something with the updates (UI, etc.) ... } });
![Page 41: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/41.jpg)
Now imagine if these live-updates came from remote changes?
![Page 42: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/42.jpg)
Realm Object Server synchronizes object changes in real-time.
Server-side Realms
Device-side Realms
Realm Object Server
Real-time Sync
![Page 43: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/43.jpg)
Push object changes server-side instantly via Node.js interface
![Page 44: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/44.jpg)
Authenticating a user
SyncCredentials me = SyncCredentials.usernamePassword(username, password, true); String authURL = "http://my.realm-auth-server.com:9080/auth"; SyncUser user = SyncUser.login(me, authURL);
![Page 45: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/45.jpg)
Open a Realm instance and get ready for synchronization
RealmConfiguration conf = new RealmConfiguration.Builder().build();
String serverURL = "realm://my.realm-server.com/~/default"; SyncConfiguration conf = new SyncConfiguration.Builder(user, serverURL).build();
Realm realm = Realm.getInstance(conf); // Any changes made to this Realm will be synced across all devices!
![Page 46: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/46.jpg)
Conflicts will occur! How do you handle them?
![Page 47: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/47.jpg)
Conflict Resolution• Operational Transform
• Well-known documented solution. • Guarantee convergence.
• At field level
• Delete always wins • Last write wins • Inserts in Lists are ordered by time
• https://realm.io/docs/realm-object-server/#conflict-resolution
![Page 48: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/48.jpg)
Trigger server-side functions based on data changes across Realms
![Page 49: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/49.jpg)
Benefits for developers• Networking abstracted away. No need to worry about
connectivity, JSON parsing, object mapping…
• Unified Data Model. Same data format and reactivity on Client and Backend.
• Straight line from Server to UI. Data can be bound directly to UI on Client.
![Page 50: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/50.jpg)
vs.
![Page 52: Introduction to Realm Mobile Platform](https://reader031.vdocuments.mx/reader031/viewer/2022032613/58ae49081a28abad338b61e1/html5/thumbnails/52.jpg)
Ressources• RealmTasks https://github.com/realm/
RealmTasks • Realm Mobile Platform https://realm.io/
products/realm-mobile-platform/ • Realm Java https://realm.io/docs/java/latest/ • More demos https://github.com/realm-demos