Last active
August 29, 2017 02:00
-
-
Save eungju/f0144d9bd97fb5d6e8893e9a1150713b to your computer and use it in GitHub Desktop.
Rx에서 reactive base type 만들 때 자주 하는 실수
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun connectDevice(userDeviceRef: UserDeviceRef, deviceAttributes: DeviceAttributes, nodeRef: PilsnerRef): Completable | |
= Completable.fromRunnable { | |
rwLock.write { | |
devicePresences[userDeviceRef.deviceId] = Presence(userDeviceRef, deviceAttributes, nodeRef) | |
userDevices.put(userDeviceRef.userId, userDeviceRef.deviceId) | |
} | |
} | |
override fun getPresencesOfUser(userId: UserId): Single<List<Presence>> | |
= Single.fromCallable { | |
rwLock.read { | |
val deviceIds = userDevices.get(userId) | |
deviceIds.mapNotNull { devicePresences[it] } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun connectDevice(userDeviceRef: UserDeviceRef, deviceAttributes: DeviceAttributes, nodeRef: PilsnerRef): Completable | |
= rwLock.write { | |
devicePresences[userDeviceRef.deviceId] = Presence(userDeviceRef, deviceAttributes, nodeRef) | |
userDevices.put(userDeviceRef.userId, userDeviceRef.deviceId) | |
}.let { Completable.complete() } | |
override fun getPresencesOfUser(userId: UserId): Single<List<Presence>> | |
= rwLock.read { | |
val deviceIds = userDevices.get(userId) | |
deviceIds.mapNotNull { devicePresences[it] } | |
}.let { Single.just(it) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment