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
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
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
510
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
410
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
940
Application Development WG Intro at AppDeveloperCon
salaboy
0
180
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
複雑なState管理からの脱却
sansantech
PRO
1
130
[FOSS4G 2024 Japan LT] LLMを使ってGISデータ解析を自動化したい!
nssv
1
210
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
270
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
170
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
334
57k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Being A Developer After 40
akosma
86
590k
Designing the Hi-DPI Web
ddemaree
280
34k
Statistics for Hackers
jakevdp
796
220k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
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