Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Byron Ferguson
    @byronferguson
        _builtCheckout
            .map((_) {
              appBloc.loading(true);
              return _;
            })
            .asyncMap(LessonService.addLesson)
            .map((_) {
              appBloc.loading(false);
              return _;
            })
            .pipe(_isAdded);
    this is called only once from the constructor
    Frank Pepermans
    @frankpepermans
    Ok, maybe try adding some doOnData on the individual streams, which can give you some hints as to which is not triggering?
    Byron Ferguson
    @byronferguson
    as I’m new to this, would I just write something like _builtCheckout.doOnData(…) within the constructor for testing?
    Frank Pepermans
    @frankpepermans
    For one, also on the PublishSubjects inside combineLatest for example. On phone so pardon the formatting:
    <Request> get _builtCheckout =>
    Observable.combineLatest2<Estimate, ShoppingCart, Request>(
    _estimate, _checkout, _checkoutRequest);
    _shoppingCart is a BehaviorSubject
    Urgh hold on
    combineLatest2(a.doOnData(print), b.doOnData(print))
    Byron Ferguson
    @byronferguson
    I’m looking at the docs for that. it isn’t clear to me that the stream is passed on. Is it?
    Frank Pepermans
    @frankpepermans
    No worries, doOnData will return the original Stream
    So the code is exactly the same, but you can register something now
    Byron Ferguson
    @byronferguson
    Thanks. I will use this as a diagnostic tool
    we’ve generally enjoyed refactoring our Flutter code to a more complete BLoC pattern
    but there are some things I know we are still struggling to fully understand how to implement “correctly"
    Frank Pepermans
    @frankpepermans
    Sure, feel free to ask questions here, more complex stuff like your example is harder to pinpoint, since many Streams are involved, so breaking it down and adding diagnostics is always a good effort
    Byron Ferguson
    @byronferguson
    while I understand it could be hard to comment, does this approach seem like it makes sense within RxDart?
    Frank Pepermans
    @frankpepermans
    BLoC and rx are very popular, I tend to do everything rx-y these days, so I'm biased :)
    From the code sample, you could swap out both map operators with doOnData there
    Dennis
    @denkuy

    I have a existing set of items that should be emitted and followed by another observable. Because those two are logically connected I have to guarantee that the initial set is emitted and directly followed by the other observable. (whenever the other observable emits a new item the "base set" changes)
    I used concatWith, but concatWith([..]) subscribes to the streams only when the first observable (my initial set of values) finished emitting. This leads to a race condition (missing values from consecutive streams). I was thinking about wrapping the concatenated in a ReplaySubject. This however will keep all items (because of the broadcast guarantee, right?).

    How can I make sure that either the second observable is buffered while the first one is emitted? Is there a ReplaySubject that only replays once?

    Order also happens to be important, a merge wouldn't work if it changes the order of the items emitted. This is about a list of items that can change. Initially I emit all items of the list in order and then only emit the changes. This should allow to bind to something like an observable list that has change notifications. I can provide some code if it helps
    Dennis
    @denkuy
    I found startWithMany in the ReplaySubject implementation. That seems to solve it
    Frank Pepermans
    @frankpepermans
    @denkuy you should give Observable.concatEager a spin :)
    ...this will subscribe to all Streams in the list and buffer events, like you require
    Dennis
    @denkuy
    @frankpepermans there it is! Many thanks
    Jannik C
    @masseelch

    Hey all, is this a possible memory leak?

    Observable.fromFuture(Future.delayed(Duration(seconds: 2))).asBroadcastStream();

    Or will the stream correctly end and close after the future completes?
    All listeners will listen to the future like this:

    await _broadCastSteram.first;

    I try to "cache" calls to a remote api. The whole code looks like this:

      Observable<List<StorageAccess>> _currentListCall$;
      List<StorageAccess> _accessCache;
    
      @override
      Future<List<StorageAccess>> list([String term]) async {
        if (_accessCache == null) {
          if (_currentListCall$ == null) {
            _currentListCall$ = Observable.fromFuture(super.list()).asBroadcastStream();
          }
          _accessCache = await _currentListCall$.first;
          _currentListCall$ = null;
        }
        return _accessCache;
      }

    super.list() returns a Future<StorageAccess>.

    Frank Pepermans
    @frankpepermans
    The Stream will close when the Future completes, so no worries :)
    Jannik C
    @masseelch
    Perfect. Thanks!
    Modestas Valauskas
    @modulovalue
    If someone could take a look at #277 Is that really expected behavior?
    Frank Pepermans
    @frankpepermans
    @brianegan see above, if you need a workaround, you could try using materialize before you apply shareValue. This way onDone will be emitted as a wrapped event?
    Brian Egan
    @brianegan
    Thanks all! Sorry for the delay -- short vacation, back tomorrow
    Frank Pepermans
    @frankpepermans
    @brianegan welcome back then :D Any objections to releasing the latest version to pub soon?
    Brian Egan
    @brianegan
    @frankpepermans Not at all! We've sat on that one for a while, probs good to get it out :)
    Frank Pepermans
    @frankpepermans
    Done :)
    Honestly can't remember all changes
    Frank Pepermans
    @frankpepermans
    @brianegan annoying bug found in the SDK, when I was tracking down some weird rxdart behavior. Think we should patch it up on our side, or just wait for the fix? https://github.com/dart-lang/sdk/issues/36965#issuecomment-492514998
    Example where it goes wrong; apply a doOnData on a broadcast Stream, it returns a single subscription Stream after the doOn transformer
    Brian Egan
    @brianegan
    Ah yah -- we should definitely make sure we return the appropriate type of Stream based on the incoming Stream (single-sub vs broadcast), but that's really rough if we can't rely on isBroadcast being accurate :/ Not sure if we can do much until the underlying issue is fixed?
    Frank Pepermans
    @frankpepermans
    Yeah had a look already, it's actually impossible to find out :/ Better to wait, the only fix I can think of now, is trying 2 null listens in a try-catch
    Frank Pepermans
    @frankpepermans
    @brianegan FYI, I've reverted travis.yml to Dart 2.2.0, since greater versions cause coveralls to fail (and the build). I've raised an issue on the SDK, but it hasn't been picked up yet
    kageeker
    @kageeker

    Hello Guys , i need help concerning Streams in dart , I already posted a question on StackOverFlow and here is the link : https://stackoverflow.com/questions/57497064/calling-drain-on-a-stream-never-returns-and-the-stream-never-closes

    Hope Someone could help cuz im really stuck, Thanks in advance :)

    Dan McGuire
    @dgmcguire
    Can I use rxdart inside provider's StreamProvider? I thought Observables could be used, but I keep getting The return type 'Observable' isn't a 'Stream<Session>', as defined by anonymous closure
    Frank Pepermans
    @frankpepermans
    @dgmcguire Observable simply inherits from Stream, so yes. Here I think you just need to provide the Observable's generic type of Session too. Looks like it is dynamic right now.
    Brian Egan
    @brianegan
    @frankpepermans Shall I go ahead and merge up this current set of PRs and ship a release? Feel like it'd be good to get that behaviorSubject fix out
    Frank Pepermans
    @frankpepermans
    was just about to ask you the same haha @brianegan :)
    you do the honours?
    ... I'll prep the release (readme & friends) meanwhile
    Brian Egan
    @brianegan
    Sounds good :)
    Frank Pepermans
    @frankpepermans
    @brianegan see ReactiveX/rxdart#323
    Brian Egan
    @brianegan
    Looks great! I'll deploy it when the master branch goes green :)
    Brian Egan
    @brianegan
    Ok, just shipped!