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
680
Realm Japan meetup #23_Java
zaki50
0
630
Realm Japan meetup #22_Java
zaki50
1
460
Realm World Tour Osaka Recent Java Updates
zaki50
0
400
Realm World Tour - ErrorProne in Realm Java
zaki50
2
390
Realm World Tour Tokyo Recent Java Updates
zaki50
3
680
Realm World Tour - ErrorProne in Realm Java
zaki50
2
620
Other Decks in Technology
See All in Technology
20241031_AWS_生成AIハッカソン_GenMuck
tsumita
0
110
신뢰할 수 있는 AI 검색 엔진을 만들기 위한 Liner의 여정
huffon
0
340
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.6k
来年もre:Invent2024 に行きたいあなたへ - “集中”と“つながり”で楽しむ -
ny7760
0
470
30万人が利用するチャットをFirebase Realtime DatabaseからActionCableへ移行する方法
ryosk7
5
350
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
27
12k
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
290k
新卒1年目が向き合う生成AI事業の開発を加速させる技術選定 / ai-web-launcher
cyberagentdevelopers
PRO
7
1.5k
Product Engineer Night #6プロダクトエンジニアを育む仕組み・施策
hacomono
PRO
1
470
サイバーエージェントにおける生成AIのリスキリング施策の取り組み / cyber-ai-reskilling
cyberagentdevelopers
PRO
2
200
生成AIの強みと弱みを理解して、生成AIがもたらすパワーをプロダクトの価値へ繋げるために実践したこと / advance-ai-generating
cyberagentdevelopers
PRO
1
180
物価高なラスベガスでの過ごし方
zakky
0
380
Featured
See All Featured
Writing Fast Ruby
sferik
626
61k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
22k
The Art of Programming - Codeland 2020
erikaheidi
51
13k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Git: the NoSQL Database
bkeepers
PRO
425
64k
YesSQL, Process and Tooling at Scale
rocio
167
14k
Designing Experiences People Love
moore
138
23k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
167
49k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
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