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
650
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
410
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
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
730
LINE Developersプロダクト(LIFF/LINE Login)におけるフロントエンド開発
lycorptech_jp
PRO
0
120
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
270
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
180
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
170
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
250
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
520
祝!Iceberg祭開幕!re:Invent 2024データレイク関連アップデート10分総ざらい
kniino
2
240
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
1
110
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.2k
AIのコンプラは何故しんどい?
shujisado
1
190
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
The Invisible Side of Design
smashingmag
298
50k
Visualization
eitanlees
146
15k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
A Philosophy of Restraint
colly
203
16k
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