https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
rx
  • r

    rakeeb

    02/13/2018, 2:53 PM
    Have you ever been confused on what the flatmap and map operators are? Hopefully this post is of help https://twitter.com/RakeebJH11/status/963423436298125312
    g
    d
    a
    • 4
    • 8
  • d

    damian

    02/23/2018, 2:05 PM
    question on combining streams: i have a state observable which can emit random states. the first emission can take up to 10-15 seconds. also, i want to display a countdown for one of the state’s properties (
    timeLeft
    in seconds). my first approach was
    combineLatest(state, Observable.interval(1, TimeUnit.SECONDS))
    but the timer seems to start before i even receive a state, thus my countdown is wrong. my next approach would be
    state.switchMap { state -> Observable.interval(1, TimeUnit.SECONDS). map { elapsedTime -> state.timeLeft - elapsedTime}}
    - is there a “better” approach to this?
    j
    • 2
    • 2
  • k

    kluck

    02/23/2018, 2:48 PM
    Hello guys, I'm looking for a way to kind of combine throttleFirst and distinctUntilChanged: if I have 2 distinct elements, no matter the delay between the emissions, I want to receive both. But if I get the same element multiple times, I want it to be throttled and get one, say every 2s. Any idea how I could manage that?
    r
    • 2
    • 5
  • r

    rudolf.hladik

    02/26/2018, 8:38 AM
    hi, is there a nice way to lazy initialize property from onSuccess/onNext of Single/Flowable ?
    r
    • 2
    • 1
  • l

    lexardi

    03/05/2018, 11:07 AM
    Hi there, as doc says, disposable is not usually disposed by itself, so I need to dispose it manually in android lifecycle (in my case). Therefore I have necessity to make disposable global variable and put
    if (disposable != null) dispose()
    in every onDestroy(). How to facilitate this process?
    m
    • 2
    • 1
  • e

    edwardwongtl

    03/05/2018, 11:11 AM
    You can also hide this boiler plate in the base class of your activity, and use a
    compositeDisposable
    to hold all
    disposable
    in a single place.
    j
    • 2
    • 2
  • u

    ubu

    03/07/2018, 6:02 PM
    Hello everyone. I have two buttons which can be clicked at the same time. I would like to get notified on the event of the button that was clicked first in this case, the second event must be ignored. What operator should I use in this case? I use RxBinding events.
    c
    m
    r
    • 4
    • 6
  • l

    locke

    03/13/2018, 2:21 PM
    @gildor Are you sure you can't
    map
    the
    BehaviorSubject
    ? Not trying to argue, but the above does allow values to be pushed into it? I'm not quite sure what you mean by the alternative solution. The general goal is to have this
    Subject
    observer listen to values of this
    List
    , and emit
    filtered
    versions of the
    List
    . New to Rx, so maybe I have the structure of the way this should work setup incorrectly. It was my understanding that
    Subjects
    act as both
    Observer
    and
    Observable
    .
    g
    m
    • 3
    • 7
  • a

    adams2

    03/14/2018, 11:08 PM
    do ya'll inject your rxjava schedulers
    z
    p
    • 3
    • 8
  • j

    jw

    03/20/2018, 8:11 PM
    upstream.publish { zip(it, it.skip(1), it.skip(2), ::Tuple) }
    • 1
    • 1
  • e

    edwardwongtl

    03/21/2018, 5:35 AM
    getItems().first(default).map{ it.isNotEmpty() }
    should do the trick
    k
    • 2
    • 3
  • g

    gildor

    04/05/2018, 11:31 AM
    Could you show an example? In general blockingFirst sounds bad and flatmap is standard way to do that
    r
    • 2
    • 16
  • j

    jw

    04/06/2018, 2:17 AM
    you want something like
    return parents.flatMapIterable { it }
        .concatMap { parent -> Single.zip(getFirst(parent), getSecond(parent), { first, second -> parent.copy(first = first, second = second) }) }
        .toList()
    🙂 1
    r
    • 2
    • 1
  • j

    jw

    04/06/2018, 2:18 AM
    the lack of polymorphic types in RxJava is such a bummer
    ☝️ 1
    r
    • 2
    • 1
  • v

    vander2675

    04/09/2018, 7:56 AM
    I love the syntax, these Extension give me so I tried modeling my Database with Extension Functions like:
    g
    • 2
    • 2
  • u

    ubu

    04/09/2018, 12:02 PM
    Hi everyone. Having the following flow of events (there’s a button click that toggles some state):
    state1 -> state2 -> state1 -> state2 -> state1 -> state2 -> ...
    When there’s no event within 3 seconds, restore default state (state1). How would I do that? Any help would be appreciated.
    l
    a
    s
    • 4
    • 12
  • u

    ursus

    04/14/2018, 3:40 AM
    is there a way around
    BiFunction { user: User, token: String -> Tuple2(user, token) }
    in rx with kotlin?
    g
    • 2
    • 4
  • u

    ursus

    04/14/2018, 3:55 AM
    is there a sort of a "sideffect flatmap"? i.e. like doOnNext but with observable, where I want to execute it but want to still keep upstream returned value
    l
    • 2
    • 2
  • u

    ubu

    04/17/2018, 6:44 PM
    Hi there. When I have a lot of Observables (
    RxView.clicks(someButton)
    ), what would be the best way to unsubscribe/disable all other buttons when ButtonX is pressed?
    e
    • 2
    • 1
  • u

    ursus

    04/18/2018, 3:14 AM
    Hi, is there a way for a custom observable created via Observable.create() to emit on scheduler specified via subscribeOn if wrapped async api changes thread of callback? (Other than observseOn...) I.e. I have bluetooth android API I am wrapping, and it automatically emits its callbacks on main thread, and id like to keep the subscribeOn scheduler
    r
    • 2
    • 1
  • g

    GurpreetSK

    04/18/2018, 6:29 PM
    Hey! Needed some help. Is there a way I can get a value out of a
    single
    if it is empty? For example, I have my DB call returning a single and want to return a boolean value on basis of whether it is empty or not. I'm doing the following currently, but it doesn't seem to work as the control gets blocked (as the table is empty).
    myDao
        .getAll(object.id())
        .isEmpty
        .blockingGet()
        .not()
    l
    • 2
    • 3
  • u

    ursus

    04/18/2018, 7:48 PM
    @GurpreetSK if value not being there is valid state, then expose it as optional ...Single<Optional<T>>
    👍 1
    g
    • 2
    • 3
  • d

    dknapp

    04/18/2018, 8:58 PM
    couldn’t you use a Maybe for that
    g
    e
    m
    • 4
    • 4
  • e

    edwardwongtl

    04/20/2018, 3:41 AM
    onErrorResumeNext { t: Throwable -> ... }
    p
    • 2
    • 5
  • j

    jw

    04/20/2018, 7:58 PM
    you almost never want to use a subject as an observer in the sense that you subscribe it to another stream
    👍 1
    u
    u
    • 3
    • 3
  • p

    Paul Woitaschek

    04/23/2018, 9:47 AM
    That's really not a managable way of handling rx. That puts ton of state all over the place. Just call
    executeRequest
    a couple of times and you're into the fun 🙂
    ☝️ 1
    u
    u
    • 3
    • 11
  • j

    jw

    04/27/2018, 5:31 PM
    .publish().refCount()
    👍 2
    u
    • 2
    • 4
  • b

    blakelee

    04/27/2018, 11:17 PM
    I used share and made it a variable so that multiple subscribers can subscribe one observable and only fire the event when there observers. However, I have a repeatWhen that fires off after a few seconds and the id is not getting updated even if I change it
    private var id = 1
    private val getItem: Observable<Any> =
        service.getItem(id) // a Single
            .toObservable()
            .repeatWhen { completed -> completed.delay(3, TimeUnit.SECONDS) }
            .share()
    • 1
    • 1
  • s

    Slackbot

    05/02/2018, 6:38 AM
    This message was deleted.
    u
    • 2
    • 1
  • u

    ursus

    05/03/2018, 1:09 PM
    guys, in rxjava2 observable when backpressured
    p
    • 2
    • 2
Powered by Linen
Title
u

ursus

05/03/2018, 1:09 PM
guys, in rxjava2 observable when backpressured
p

Pandu

05/03/2018, 10:48 PM
Shouldn't you be using `Flowables ?
u

ursus

05/05/2018, 9:34 PM
no, I just wanted to know what happens in Observable when upstream is faster then downstream, turns out as Roman pointed out, producer just blocks
View count: 1