Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
オフラインファーストなアプリケーション開発
Search
zaki50
March 09, 2017
Technology
1
2.5k
オフラインファーストなアプリケーション開発
DroidKaigi 2017 Day1
16:00-16:50 Room 3
zaki50
March 09, 2017
Tweet
Share
More Decks by zaki50
See All by zaki50
I/O Extended 2018 @Tokyo Android1
zaki50
3
1.2k
簡単高速なDIライブラリToothpick
zaki50
1
180
Android Studio 3.0 profilerハンズオン
zaki50
2
690
Realm Japan meetup #23_Java
zaki50
0
640
Realm Japan meetup #22_Java
zaki50
1
470
Realm World Tour Osaka Recent Java Updates
zaki50
0
410
Realm World Tour - ErrorProne in Realm Java
zaki50
2
400
Realm World Tour Tokyo Recent Java Updates
zaki50
3
690
Realm World Tour - ErrorProne in Realm Java
zaki50
2
640
Other Decks in Technology
See All in Technology
WernerVogelsのKeynoteで語られた6つの教訓とOps
hatahata021
2
220
目玉アップデート!のSageMaker LakehouseとUnified Studioは何たるかを見てみよう!
nayuts
0
150
re:Invent2024のIaC周りのアップデート&セッションの共有/around-re-invent-2024-iac-updates
tomoki10
0
840
『GRANBLUE FANTASY: Relink』続・最高の「没入感」を実現するカットシーン制作手法とそれを支える技術
cygames
0
100
知らない景色を見に行こう チャンスを掴んだら道が開けたマネジメントの旅 / Into the unknown~My management journey~
kakehashi
11
1.3k
pmconf2024_UPSIDER
upsider_tech
0
8k
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
Autonomous Database サービス・アップデート (FY25)
oracle4engineer
PRO
0
280
2000年てづくりキーボードの旅
tagomoris
1
170
宇宙最速のランチRecap LT会(開発者ツール&運用監視編)
nnydtmg
1
190
宇宙最速のランチRecap LT会(AWS re:Invent 2024)
watany
1
420
長年運用されているサービスの主要データ移行をサービス停止せず安全にリリースしました
phayacell
2
210
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
45
6.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Visualization
eitanlees
145
15k
Building Adaptive Systems
keathley
38
2.3k
Rails Girls Zürich Keynote
gr2m
94
13k
Building an army of robots
kneath
302
44k
Unsuck your backbone
ammeep
669
57k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Transcript
[email protected]
ΦϑϥΠϯϑΝʔετ ΞϓϦέʔγϣϯ։ൃ 2017/3/9 Droid Kaigi 2017 16:00- Room3 Makoto
Yamazaki (@zaki50)
[email protected]
Makoto Yamazaki Realm / uPhyca Inc. @zaki50
[email protected]
agenda ΦϑϥΠϯϑΝʔετͱ ΦϑϥΠϯϑΝʔετͰͷٕज़త՝ Realmతղܾࡦ σϞ ·ͱΊ
[email protected]
ΦϑϥΠϯϑΝʔ ετʁ
[email protected]
ΦϑϥΠϯϑΝʔετ ݩʑWebͰͷߟ͑ํ ࠷ॳ͔ΒΦϑϥΠϯͰͷಈ࡞Λߟ͑ͨWebαʔϏε ϒϥβ͕ϩʔΧϧʹετϨʔδΛ࣋ͯΔΑ͏ʹͳͬ ͨ
[email protected]
ϞόΠϧ Billions of Minutes Online (USA) 0 250 500
750 1000 1250 1500 Jun 2013 Jun 2014 Jun 2015 Desktop Mobile App Mobile Browser
[email protected]
ϞόΠϧͰͷΦϑϥΠϯϑΝʔετ αʔϏεΛޭͤ͞ΔͨΊʹྑ͍ΞϓϦ͕ඞཁ ΦϑϥΠϯͰͷར༻ίΞػೳ ར༻ऀΦϑϥΠϯͰ͑Δ͜ͱΛͨΓલͱࢥ͍࢝ Ίͨ
[email protected]
ඞཁͳػೳ αʔόʔͱͷ௨৴ ΦϑϥΠϯ࣌ͷͨΊͷετϨʔδʗσʔλϕʔε ΦϯϥΠϯʹͳͬͨ࣌ͷσʔλಉظ ͜ΕΒ͕ࣗવͳܗͰΞϓϦͷػೳʹΈࠐ·Ε͍ͯΔ͜ͱ
[email protected]
௨৴෦ͷ՝ Java, React Native, Xamarin σʔλϕʔε ௨৴ʗσʔλಉظػೳ Android
[email protected]
௨৴ͷ՝
[email protected]
σʔλϕʔεͷ՝ ΦϑϥΠϯ࣌༻ͷϩδοΫΛผ్࣮͢ Δ͜ͱ͕ඞཁ ΦϯϥΠϯ࣌: αʔόʔ͔Βऔಘ(ͱอଘ) ΦϑϥΠϯ࣌: σʔλϕʔε͔Βऔಘ
[email protected]
ಉظͷ՝ ࠷৽ใͷऔಘλΠϛϯά ΦϯϥΠϯʹͳͬͨΒࡍͷΞοϓϩʔυ ෳͰͷมߋͷ౷߹ ਖ਼ͱ͍ͯ͠
[email protected]
Realm Mobile Platform͕ղܾ͠·͢
[email protected]
Realm Mobile Platform ෳσόΠεͷσʔλϕʔεΛϦΞϧλΠϜಉظ ΦϑϥΠϯͰϩʔΧϧͷσʔλϕʔε͕͑Δ ΦϑϥΠϯ࣌ͷมߋিಥΛࣗಈղܾ SD SD SD
SDK SD Object Store Sync Server RMP Dashboar d Event Auth System Encryption Layer Rules Engine Data Connect ors Real-time Sync
[email protected]
RMPͰͷ௨৴ߏ Java, React Native, Xamarin σʔλϕʔε ௨৴ʗσʔλಉظػೳ Android
[email protected]
୯ͳΔಉظҎ্ͷ͍ํ
[email protected]
Realm Mobile Database
Ϟσϧͷఆٛ
[email protected]
public class Task extends RealmObject { @PrimaryKey public
String id = UUID.randomUUID().toString(); @Required public Date createdAt = new Date(); public String text; public boolean completed; }
RealmΠϯελϯεͷऔಘ
[email protected]
Realm realm = Realm.getDefaultInstance(); // 様々な機能へアクセスするための入り口。 // データベースコネクションと捉えることも可能。
... // 終わったら忘れずに閉じる realm.close();
σʔλͷૠೖ
[email protected]
final Task task = new Task(); task.text =
"原稿を書く"; realm.executeTransactionAsync(new Realm.Transaction() { @Override public void execute(Realm realm) { realm.insert(task); } });
σʔλͷݕࡧͱͷΞΫηε
[email protected]
final RealmResults<Task> completedTasks = realm.where(Task.class) .equalTo("completed", true) .findAll();
for (Task completedTask : completedTasks) { Log.d("debug", completedTask.text); }
σʔλͷߋ৽
[email protected]
RealmResults<Task> allTasks = realm.where(Task.class) .findAllSorted("createdAt"); // たとえばリストで position
== 5 の要素がタップされた時 final Task task = allTasks.get(5); realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { task.completed = true; } });
σʔλͷআ
[email protected]
RealmResults<Task> allTasks = realm.where(Task.class) .findAllSorted("createdAt"); // たとえばリストで position
== 5 の要素がスワイプされた時 final Task task = allTasks.get(5); realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { task.deleteFromRealm(); } });
มߋ௨
[email protected]
completedTasks.addChangeListener( new OrderedRealmCollectionChangeListener<RealmResults<Task>>() { @Override public void onChange(RealmResults<Task>
tasks, OrderedCollectionChangeSet changeSet) { // changeSetから、追加/削除/更新があった要素を取得 可能 } });
Realmͷ͍ํ·ͱΊ
[email protected]
• Ϋϥεͱͯ͠ϞσϧΛఆٛ͢Δ • RealmΠϯελϯεΛऔಘ͢Δ • τϥϯβΫγϣϯͷதͰՃߋ৽Λߦ͏ • ݕࡧΛߦ͍ɺදࣔʹඞཁͳΦϒδΣΫτΛRealmResultsݸผͷ
ϞσϧΦϒδΣΫτͱͯ͠औಘ͢Δ • RealmResultsϞσϧΦϒδΣΫτʹηοτͨ͠ϦεφʔͰ࠷৽ ͷใΛड͚औΓදࣔ͢Δ
ͦͷଞͷಛ
[email protected]
• ߴ • Ԇϩʔυ • σʔλϕʔε҉߸Խ • ΫϩεϓϥοτϑΥʔϜ(Android,
iOS) • etc.
ηοτΞοϓ
[email protected]
// in build.gradle buildscript { repositories { jcenter()
} dependencies { classpath "io.realm:realm-gradle-plugin:3.0.0" } } // in app/build.gradle apply plugin: 'realm-android'
[email protected]
σʔλಉظͷࣗવͳ֦ு
σʔλͷߋ৽
[email protected]
RealmResults<Task> allTasks = realm.where(Task.class) .findAllSorted("createdAt"); // たとえばリストで position
== 5 の要素がタップされた時 final Task task = allTasks.get(5); realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { task.completed = true; } });
มߋ௨
[email protected]
completedTasks.addChangeListener( new OrderedRealmCollectionChangeListener<RealmResults<Task>>() { @Override public void onChange(RealmResults<Task>
tasks, OrderedCollectionChangeSet changeSet) { // changeSetから、追加/削除/更新があった要素を取得可能 } });
σʔλͷߋ৽
[email protected]
Server-side Realms completed = true; completed = true;
onChange()
ϩάΠϯ
[email protected]
// 認証 SyncCredentials credential = SyncCredentials.usernamePassword(email, password, false);
SyncUser user = SyncUser.login(credential, RealmTasksApplication.AUTH_URL); SyncConfiguration defaultConfig = new SyncConfiguration.Builder(user, RealmTasksApplication.REALM_URL) .build(); Realm.setDefaultConfiguration(defaultConfig);
[email protected]
Demo
[email protected]
িಥղܾ
ඪ४ͷղܾϧʔϧ
[email protected]
আৗʹ༏ઌ͞ΕΔ ಉ͡ϓϩύςΟͷฤूޙউͪ Ϧετͷૠೖ࣌ؒॱ Operational TransformʹΑΓɺ֤ʹదͳ มߋηοτ͕͞ΕΔ
[email protected]
CAPఆཧ ConsistencyʢҰ؏ੑʣ AvailabilityʢՄ༻ੑʣ Partition Toleranceʢஅੑʣ ̎ͭ·Ͱ͔͠ಉ࣌ʹຬͨ͢͜ͱ͕Ͱ͖ͳ͍
[email protected]
CAPఆཧ ConsistencyʢҰ؏ੑʣ AvailabilityʢՄ༻ੑʣ Partition Toleranceʢஅੑʣ ҰൠతͳRDB
[email protected]
CAPఆཧ ConsistencyʢҰ؏ੑʣ AvailabilityʢՄ༻ੑʣ Partition Toleranceʢஅੑʣ Apache HBaseɺMongoDB
[email protected]
CAPఆཧ ConsistencyʢҰ؏ੑʣ AvailabilityʢՄ༻ੑʣ Partition Toleranceʢஅੑʣ DNSͳͲɻRealm Mobile Platform͜Ε
[email protected]
Eventual Consistency Strong Eventual Consistency Strong Consistency Ұ؏ੑ
[email protected]
·ͱΊ
[email protected]
௨৴ͷ σʔλϕʔεͷ ಉظͷ ͍͜͠ͱRMPʹ·͔ͤΑ͏
ࢀߟใ
[email protected]
realm.io