Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Johan Larsson
    @JohanLarsson
    But typed
    I'm not super happy with the names Pair() and Paired<T>
    Dorus
    @Dorus
    Buffer(2,1).Select(a => new Paired(a[0], a[1]))
    Johan Larsson
    @JohanLarsson
    Thought about WithPrevipous()
    Dorus
    @Dorus
    Why not use a tupel?
    {Previous: ..., Current: ...}
    Johan Larsson
    @JohanLarsson
    Why not use a struct?
    I don't use value tuples much so don't really know how the named fields work when it is in a library
    Dorus
    @Dorus
    Can those be generic? Tupels can have named fields.
    It depends on what version of .net and C# you have. Tupels are kinda new.
    Can those be generic?
    Dorus
    @Dorus
    But just your own class seems fine too.
    Johan Larsson
    @JohanLarsson
    Is that about struct?
    Dorus
    @Dorus
    Yeah i was wondering if a struct could be generic.
    But i see no harm in using a class, you could argue about the name indeed.
    Paired with current and previous fields is kinda weird.
    Johan Larsson
    @JohanLarsson
    agreed
    Dorus
    @Dorus
    Buffered?
    Johan Larsson
    @JohanLarsson
    thought about it
    Dorus
    @Dorus
    In RxJs they have Pairwise as operator name.
    Johan Larsson
    @JohanLarsson
    it is probably better as it suggests order
    Dorus
    @Dorus
    https://rxjs.dev/api/operators/pairwise
    But it just returns an array. They didn't name it.
    Johan Larsson
    @JohanLarsson
    My thinking was Pair() -> Paired<T> like Timestamp() -> Timestamped<T> but was not super happy with it.
    Dorus
    @Dorus
    I would use Pair<T> and Timestamp<T>, but then your operator and type have the same name. Is that a problem?
    Johan Larsson
    @JohanLarsson
    Pair() is not awesome either
    Dorus
    @Dorus
    Pairwise() : Observable<Pair<T>>?
    Johan Larsson
    @JohanLarsson
    probably better
    or Pairwise() : Observable<Pairwised<T>>
    Pair<T> is not ideal as a public type with fields Current and Previous
    Dorus
    @Dorus
    Idk if i like verb type names.
    Yeah but Pairwised doesn't improve that.
    Dorus
    @Dorus
    interesting
    Johan Larsson
    @JohanLarsson
    ^ is the reason I'm going on about Paired<T> stay consistent with the framework
    Dorus
    @Dorus
    But then you can write almost all your types in paste tense.
    But it's not wrong since we work with async data. Mmmm
    I can agree with consistency.
    aka Observable<Timestamp<T>> timestamp(this Observable<T> source, IScheduler scheduler) in C#
    Adam Buchanan
    @RejectKid
    @Dorus Perfect thank you!
    RedlineTriad
    @RedlineTriad
    Is there an easier way to return the last element of an Observable on subscribe other than wrapping than wrapping it in a BehaviourSubject?
    José Manuel Nieto
    @SuperJMN
    I don't think so :(
    Dorus
    @Dorus
    @SuperJMN I think you can ;-)
    José Manuel Nieto
    @SuperJMN
    Oh, yes, now that you say! Sorry, I'm such a pessimistic person sometimes ! haha
    RedlineTriad
    @RedlineTriad
    @Dorus wouldn't that return all the previous ones? i only want the most recent.
    Dorus
    @Dorus
    @RedlineTriad You can pass in the buffer size. Set it to 1.

    See

    Replay<TSource>(IObservable<TSource>, Int32)
    Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize notifications.

    RedlineTriad
    @RedlineTriad
    Ah, yep, that sound like what i want.