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
640
Realm Japan meetup #22_Java
zaki50
1
460
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
680
Realm World Tour - ErrorProne in Realm Java
zaki50
2
630
Other Decks in Technology
See All in Technology
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
3
630
AIチャットボット開発への生成AI活用
ryomrt
0
170
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
The Rise of LLMOps
asei
8
1.7k
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
1
110
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
10
1.2k
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
140
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.2k
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
Featured
See All Featured
Docker and Python
trallard
40
3.1k
Making Projects Easy
brettharned
115
5.9k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Speed Design
sergeychernyshev
25
620
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Designing for Performance
lara
604
68k
KATA
mclloyd
29
14k
A Modern Web Designer's Workflow
chriscoyier
693
190k
What's in a price? How to price your products and services
michaelherold
243
12k
Done Done
chrislema
181
16k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
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