Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AutoDispose
Search
Moyuru Aizawa
June 12, 2017
Technology
1
730
AutoDispose
Rx Ja Night #2
TwitterID変えました。@lvla0805 -> @MoyuruAizawa
Moyuru Aizawa
June 12, 2017
Tweet
Share
More Decks by Moyuru Aizawa
See All by Moyuru Aizawa
BLUETOOTH_SCAN and iBeacon
lvla
1
120
graphicsLayer
lvla
0
240
BluetoothDevice.getName()に裏切られた話
lvla
0
380
Jetpack Composeで画像クロップ機能を実装する
lvla
0
1.2k
Jetpack Compose drag gesture and pinch gesture
lvla
1
4k
Jetpack Compose Layout API
lvla
1
680
BLEを使ったアプリを継続的に開発するために
lvla
0
1.1k
RecyclerView.ItemAnimator
lvla
1
340
RecycledViewPool
lvla
1
240
Other Decks in Technology
See All in Technology
Kiro を用いたペアプロのススメ
taikis
3
1.2k
M&Aで拡大し続けるGENDAのデータ活用を促すためのDatabricks権限管理 / AEON TECH HUB #22
genda
0
140
CARTAのAI CoE が挑む「事業を進化させる AI エンジニアリング」 / carta ai coe evolution business ai engineering
carta_engineering
0
2.1k
高度サイバー人材育成専科(後半)
nomizone
0
230
IAMユーザーゼロの運用は果たして可能なのか
yama3133
2
510
AWSインフルエンサーへの道 / load of AWS Influencer
whisaiyo
0
180
AWSの新機能をフル活用した「re:Inventエージェント」開発秘話
minorun365
2
230
Fashion×AI「似合う」を届けるためのWEARのAI戦略
zozotech
PRO
2
1k
マイクロサービスへの5年間 ぶっちゃけ何をしてどうなったか
joker1007
17
7.3k
AI時代のワークフロー設計〜Durable Functions / Step Functions / Strands Agents を添えて〜
yakumo
3
1.5k
AIの長期記憶と短期記憶の違いについてAgentCoreを例に深掘ってみた
yakumo
4
470
AWS re:Invent 2025~初参加の成果と学び~
kubomasataka
0
160
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Navigating Team Friction
lara
191
16k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
180
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
220
Ruling the World: When Life Gets Gamed
codingconduct
0
92
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
680
Rebuilding a faster, lazier Slack
samanthasiow
85
9.3k
It's Worth the Effort
3n
187
29k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
0
210
Game over? The fight for quality and originality in the time of robots
wayneb77
1
64
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