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
AutoDispose
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Moyuru Aizawa
June 12, 2017
Technology
750
1
Share
AutoDispose
Rx Ja Night #2
TwitterID変えました。@lvla0805 -> @MoyuruAizawa
Moyuru Aizawa
June 12, 2017
More Decks by Moyuru Aizawa
See All by Moyuru Aizawa
BLUETOOTH_SCAN and iBeacon
lvla
1
140
graphicsLayer
lvla
0
260
BluetoothDevice.getName()に裏切られた話
lvla
0
400
Jetpack Composeで画像クロップ機能を実装する
lvla
0
1.3k
Jetpack Compose drag gesture and pinch gesture
lvla
1
4.2k
Jetpack Compose Layout API
lvla
1
700
BLEを使ったアプリを継続的に開発するために
lvla
0
1.1k
RecyclerView.ItemAnimator
lvla
1
350
RecycledViewPool
lvla
1
270
Other Decks in Technology
See All in Technology
開発チームとQAエンジニアの新しい協業モデル -年末調整開発チームで実践する【QAリード施策】-
kaomi_wombat
0
280
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
3
2k
Embeddings : Symfony AI en pratique
lyrixx
0
430
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
4
1.3k
来期の評価で変えようと思っていること 〜AI時代に変わること・変わらないこと〜
estie
0
130
Oracle Cloud Infrastructure:2026年3月度サービス・アップデート
oracle4engineer
PRO
0
220
Bill One 開発エンジニア 紹介資料
sansan33
PRO
5
18k
互換性のある(らしい)DBへの移行など考えるにあたってたいへんざっくり
sejima
PRO
0
470
Datadog で実現するセキュリティ対策 ~オブザーバビリティとセキュリティを 一緒にやると何がいいのか~
a2ush
0
180
Microsoft Fabricで考える非構造データのAI活用
ryomaru0825
0
540
非同期・イベント駆動処理の分散トレーシングの繋げ方
ichikawaken
1
250
Physical AI on AWS リファレンスアーキテクチャ / Physical AI on AWS Reference Architecture
aws_shota
1
200
Featured
See All Featured
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
92
Code Review Best Practice
trishagee
74
20k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
310
Into the Great Unknown - MozCon
thekraken
40
2.3k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
120
What's in a price? How to price your products and services
michaelherold
247
13k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
500
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Raft: Consensus for Rubyists
vanstee
141
7.4k
How to Ace a Technical Interview
jacobian
281
24k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
140
Transcript
AutoDispose @lvla0805
lvla Ѫᖒ๖ (Moyuru Aizawa) - Kotlin engineer at CyberAgent, Inc.
- FRESH! lvla0805
override fun onCreate(…) { … Flowable.interval(1, TimeUnit.SECONDS) .subscribe { sec
-> textView.text = "${sec}s" } } Disposable
var disposable: Disposable? = null override fun onCreate(…) {
… disposable = Flowable.interval(1, TimeUnit.SECONDS) .subscribe { sec -> textView.text = "${sec}s" } } override fun onDestroy() { disposable?.dispose() } Disposable
val disposables = CompositeDisposable() override fun onCreate(…) { …
Flowable.interval(1, TimeUnit.SECONDS) .subscribe { sec -> textView.text = "${sec}s" } .addTo(disposables) } override fun onDestroy() { disposables.dispose() super.onDestroy() } CompositeDisposable
AutoDispose
override fun onCreate(…) { … Flowable.interval(1, TimeUnit.SECONDS) .to(FlowableScoper<Long>(this)) .subscribe {
sec -> textView.text = "${sec}s" } } AutoDispose
enum class ActivityLifeCycle { CREATE, …, DESTROY } AutoDispose
public interface LifecycleScopeProvider<E> { Observable<E> lifecycle(); Function<E, E> correspondingEvents(); E
peekLifecycle(); } AutoDispose
abstract class RxActivity : AppCompatActivity(), LifecycleScopeProvider<ActivityLifeCycle> { … } AutoDispose
‣ lifecycle() ‣ returns an Observable of lifecycle events. ‣
This should be backed by a BehaviorSubject or something similar ‣ correspondingEvents() ‣ a mapping of events to corresponding ones. ‣ i.e. CREATE -> DESTROY ‣ peekLifecycle() ‣ returns the current lifecycle state of the object. AutoDispose
abstract class RxActivity : AppCompatActivity(), LifecycleScopeProvider<ActivityLifeCycle> { private val
lifecycle = BehaviorSubject.create<ActivityLifeCycle>() private lateinit var currentEvent: ActivityLifeCycle override fun lifecycle(): Observable<ActivityLifeCycle> = lifecycle override fun correspondingEvents(): Function<ActivityLifeCycle, ActivityLifeCycle> { return Function { lastEvent: ActivityLifeCycle -> when (lastEvent) { CREATE -> DESTROY else -> throw OutsideLifecycleException("Activity was destroyed") } } } override fun peekLifecycle() = currentEvent } AutoDispose
class MainActivity : RxActivity() { … override fun onCreate(…) {
Flowable.interval(1, TimeUnit.SECONDS) .to(FlowableScoper<Long>(this)) .subscribe { sec -> textView.text = "${sec}s" } } } AutoDispose
Thank you