Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    David Stemmer
    @weefbellington
    ASG is very active and has a very enthusiastic rxjava community
    but because it's invite-only and Android-specific, it's kind of isolated from the rest of the RxJava community
    Alessandro Vermeulen
    @spockz
    @weefbellington , was that a remark regarding my question?
    Dorus
    @Dorus
    @spockz No, that wont print because the observable did not end in onCompleted, it ended in onError
    Also you are creating 2 new observables
    So you can only subscribe to one like that
    The correct way is
    val obs = rx.Observable.error(new IllegalStateException("foo"))
        .doOnError(new Action1[Throwable] {
          override def call(t: Throwable): Unit = println(t)
        })
        .doOnCompleted(new Action0 {
          override def call(): Unit = println("DOne")
        });
    Alessandro Vermeulen
    @spockz
    @Dorus of course!!!
    Alessandro Vermeulen
    @spockz
    This message was deleted
    David Stemmer
    @weefbellington
    @spockz not related :)
    just some rxjava community gossip
    Alessandro Vermeulen
    @spockz
    @Dorus suppose I want to only create one Observable per resource, and have that resource freed when all subscribers of the Observable are unsubscribed. Could I do that by using Observable.using? Like below. Or is that way to convoluted?
    val watcher: java.nio.file.WatchService
    var outputStreams: Map[WatchKey, Subject[WatchEvent[Path]] = Map.empty
    var queries: Map[Path, Observable[WatchEvent[Path]] = Map.empty
    
    def watch(dir: Path) =
       // if dir is contained in queries return it, otherwise create it by using watch2
    
    def watch2(dir: Path): Observable[WatchEvent[Path]] = 
        Observable.using(dir.register(watcher), key => createObservable(dir, key), key => key.cancel())
    
    def createObservable(dir:Path, watchKey: WatchKey): Observable[WatchEvent[Path]] = {
      if (!outputStreams.contains(watchKey)) {
         // return create publish subject and add it to outputStreams
         // add the subject to queries as well
      } else {
         // return the subject from the map
      }
    @weefbellington I do keep reading beef wellington...
    Dorus
    @Dorus
    @spockz That sounds like the scenario where you use .publish().refCount()
    Observable.using still creates a new resource every time you subscribe. But .publish().refCount() will make you multicast.
    Alessandro Vermeulen
    @spockz
    would that be Observable.using(...).publish().refCount() then?
    Dorus
    @Dorus
    You still need to think about what you want to push onto your subscribers. If it's only live data, publish would work. If they also need to get the most recent element on subscription you could use replay(1) etc.
    Alessandro Vermeulen
    @spockz
    @Dorus only live data is necessary
    Dorus
    @Dorus
    using is only used to tie the lifetime of the resource to the subscription.
    Shouldn't it be Observable.using(() -> dir.register(watcher), ....?
    There are other ways to solve it, but using would certainly be valid.
    Alessandro Vermeulen
    @spockz
    So I can change it to as follows:
    val watcher: java.nio.file.WatchService
    var outputStreams: Map[WatchKey, Subject[WatchEvent[Path]] = Map.empty
    var queries: Map[Path, Observable[WatchEvent[Path]] = Map.empty
    
    def watch(dir: Path) =
       // if dir is contained in queries return it, otherwise create it by using watch2 and add it to queries
    
    def watch2(dir: Path): Observable[WatchEvent[Path]] = 
        Observable.using(dir.register(watcher), key => createObservable(dir, key), key => key.cancel()).publish().refCount()
    
    def createObservable(dir:Path, watchKey: WatchKey): Observable[WatchEvent[Path]] = {
         // return create publish subject and add it to outputStreams
         // we assume that publish() and refCount() will take of having only 1 direct subscriber
    }
    @Dorus and yes, in Java, but in RxScala the using method is defined with a call by name argument for the resource factory.
    Dorus
    @Dorus
    ooh cool. I'm not that familiar with Scala :)
    Alessandro Vermeulen
    @spockz
    @Dorus its a nice feature which enables 'laziness' transparently :)
    @Dorus there is also share():
     public final Observable<T> share() {
            return publish().refCount();
        }
    Dorus
    @Dorus
    yeah i know. Forgot if that was a RxJava thing ^_^
    Alessandro Vermeulen
    @spockz
    @Dorus how do you use RxJava ?
    Dorus
    @Dorus
    not really
    Using Rx.Net mostly, and even that not much right now. Mostly hanging out in these gitter channels to help people out :)
    RxJS is the most active, so i'm getting more familiar with that now.
    Alessandro Vermeulen
    @spockz
    @Dorus amazing! it is much appreciated. :)
    @Dorus is there a different channel for all of the dialects?
    Dorus
    @Dorus
    yeah
    I'm not sure why RxJava is not connected to the rest.
    Alessandro Vermeulen
    @spockz
    different repos?
    in different orgs
    ReactiveJS is pretty busy with almost 1k participant
    Dorus
    @Dorus
    ReactiveJS has nothing to do with Rx right?
    Alessandro Vermeulen
    @spockz
    @Dorus sorry meant RxJS :)
    Dorus
    @Dorus
    yeah, very active.
    Alessandro Vermeulen
    @spockz
    I could imagine that React and Angular would use RxJS for their streaming purposes instead of their own stuff..
    David Stemmer
    @weefbellington
    @Dorus are you an Rx contributor?
    Dorus
    @Dorus
    ?
    David Stemmer
    @weefbellington
    I mean do you contribute to one of the frameworks itself
    Dorus
    @Dorus
    code? Not really, i did fill some bugs
    David Stemmer
    @weefbellington
    I was just curious, I know Artem Zinnatullin works on RxJava, just thought you might be a contributor since you're the most active in this channel
    Dorus
    @Dorus
    I haven't seen many contributors yes in these channels, they usually do respond quickly to github issues.