Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:46
    niklas-wortmann edited #5419
  • 14:44
    niklas-wortmann commented #5419
  • 14:43
    niklas-wortmann commented #5419
  • 14:42
    niklas-wortmann edited #5419
  • 14:41

    niklas-wortmann on master

    docs(skip): add description and… (compare)

  • 14:41
    niklas-wortmann closed #5773
  • 14:41
    niklas-wortmann closed #4868
  • 14:41

    niklas-wortmann on master

    docs(last): add description and… (compare)

  • 14:41
    niklas-wortmann closed #5774
  • 14:41
    niklas-wortmann closed #4870
  • 07:41
    hardikpthv commented #5773
  • 07:40
    hardikpthv synchronize #5773
  • 07:37
    hardikpthv synchronize #5774
  • 05:34
    cartant edited #5066
  • 01:31
    benlesh opened #5782
  • 00:49
    benlesh review_requested #5781
  • 00:49
    benlesh opened #5781
  • 00:19

    benlesh on master

    fix(bindNodeCallback): ensure u… (compare)

  • 00:18
    benlesh closed #5780
  • Sep 29 23:05

    benlesh on master

    refactor(generate): Use an actu… (compare)

Will Mruzek
@mruzekw
Would it be any different if a click was the trigger to switch observables?
Derek
@derekkite
@mruzekw there are examples of a search bar where the event triggers an http call that is interrupted via switchmap if the user types something more.
Will Mruzek
@mruzekw
To make this even simpler, is there a way to receive a stream of numbers one at a time? Say when I click a button?
Karsten Pruehss
@kpruehss
@mruzekw if you want a stream of individual numbers rather then all the numbers at once, you should use from() instead of of() i think
Will Mruzek
@mruzekw
I mean, I'm sure I can create a stream of numbers with either one
The question is getting each num one at a time
Err, per click in this case
Dorus
@Dorus
@mruzekw You could put zip before the switchMap, or inside.
const setOfSetOfNums$ = merge(
  of([4,5,6,7]).pipe(delay(50)),
  of([0,1,2,3]),
).pipe(
  switchMap(context => zip(interval(1000), from(context))),
  map(([_, hand]) => hand)
)
Will Mruzek
@mruzekw
Thanks, @Dorus! That worked
Now is there a way to do a head-tail type operation on an observable?
Dorus
@Dorus
There is finalize or concat to add actions on the tail. Or just use the complete callback.
I'm not exactly sure what you mean
Will Mruzek
@mruzekw
Well, I'd like the first value of an observable to pass through, but the rest be released on click
So I was thinking I could split and merge
Something like
        return concat(
          handsToDeal$.pipe(
            first(),
            map(hand => [null, hand])
          )
          zip(dealIntent$, handsToDeal$.pipe(skip(1)))
        )
Dorus
@Dorus
zip(source, fromEvent(el, 'click').pipe(startWith()))
this does queue the clicks, that might not be intended
source.pipe(concatMap(e => fromEvent(el, 'click').pipe(mapTo(e))))
Will Mruzek
@mruzekw
startWith() without a arg just uses the first value in the stream?
Dorus
@Dorus
startWith() without an arg will emit undefined i think.
Might be better to put some value in there to avoid TS complaining, but it's not really important what you put in.
My second example with concatMap would not buffer clicks instead.
Will Mruzek
@mruzekw
Oh I see, the first is essentially a ghost click
Dorus
@Dorus
yup
Will Mruzek
@mruzekw
Thanks!
Yeah, I had to put something in for it to work
startWith(null)
Do you just pick this stuff up with experience? Or is there a good resource for thinking in streams?
Dorus
@Dorus
Both i guess
Will Mruzek
@mruzekw
Do you have a fav resource? Other than the official docs?
Dorus
@Dorus
There are good resources but you need to play with it to really get the hang of it.
I learned a lot from http://introtorx.com/ but that's Rx.net mostly.
Will Mruzek
@mruzekw
Sure, I think I get most hung up on the combination
Err, using combinations for complex interactions
Dorus
@Dorus
Lets see if i can find my linkdump
Will Mruzek
@mruzekw
:D
Been a while since i checked if they where all still online.
I recently also found this playground.
Will Mruzek
@mruzekw
Thanks! I'll check these out
Nico
@ndcunningham
wow @Dorus
Dorus
@Dorus
hi @ndcunningham
Nico
@ndcunningham
:wave:
Nico
@ndcunningham
@Dorus RxJS and PouchDB have you ever done?
probably there are wrappers
Dorus
@Dorus
Never heard of PouchDB
I think it uses events? You can just use fromEvent to connect to it.
@ndcunningham Need help converting their on(...) to observable? Looks like half the api uses promises so those should combine too.
Nico
@ndcunningham
yea i was looking into it. It seems to be able to be converted, i was just wondering if you had experience :sweat_smile: