Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
AutoDispose
Search
Moyuru Aizawa
June 12, 2017
Technology
770
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AutoDispose
Rx Ja Night #2
TwitterID変えました。@lvla0805 -> @MoyuruAizawa
Moyuru Aizawa
June 12, 2017
Transcript
14 slides
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
More Decks by Moyuru Aizawa
See All by Moyuru Aizawa
BLUETOOTH_SCAN and iBeacon
lvla
1
170
graphicsLayer
lvla
0
330
BluetoothDevice.getName()に裏切られた話
lvla
0
450
Jetpack Composeで画像クロップ機能を実装する
lvla
0
1.4k
Jetpack Compose drag gesture and pinch gesture
lvla
1
4.4k
Jetpack Compose Layout API
lvla
1
740
BLEを使ったアプリを継続的に開発するために
lvla
0
1.2k
RecyclerView.ItemAnimator
lvla
1
400
RecycledViewPool
lvla
1
320
Other Decks in Technology
See All in Technology
攻撃と守りは何が変わり、何が変わらないのか~最近の不正アクセスから考える、リスク評価と標準の使いどころ
oidfj
2
390
AIフレンドリーなGenerative UIをJSXで
uhyo
3
1.2k
AI時代の開発組織における、QAの体制とロールの再設計
sansantech
PRO
0
140
正しくWeb サイトを守るためのコンテンツセキュリティーポリシー
hinalin
1
900
FPGAでアクティブセンシングがやりたくてカメラモジュールを自作した話
ryuz88
0
170
Claude Certified Developer – Professional 試験対策
shinoisa
0
340
ローカルLLMによるデジタルフォレンジック支援ハーネスの設計と実装
sumeshi
0
690
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
5
18k
品質を積み上げられるようにする
goyoki
6
2.8k
AIエージェントの認証がまとめて進化! ~pre:Inventで来た3つのアップデート~
minorun365
PRO
2
300
Web Performance Is a Journey [PerfNow 2026]
tammyeverts
3
200
デザインシステムのフィードバックループをほぼ自動化した話
tongari07
1
1.4k
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.5k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Deep Space Network (abreviated)
tonyrice
0
440
Large-scale JavaScript Application Architecture
addyosmani
516
110k
[SF Ruby Conf 2025] Rails X
palkan
3
1.6k
The Limits of Empathy - UXLibs8
cassininazir
2
810
Chasing Engaging Ingredients in Design
codingconduct
0
410
Exploring anti-patterns in Rails
aemeredith
4
590
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
310
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
6
970
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
830