Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 26 19:48
    jakovljevic-mladen opened #6655
  • Oct 25 18:54
    kwonoj closed #6653
  • Oct 25 18:54
    kwonoj commented #6653
  • Oct 25 13:14
    karptonite opened #6654
  • Oct 25 08:31
    voliva commented #6653
  • Oct 25 08:31
    voliva commented #6653
  • Oct 25 08:00
    lamisChebbi commented #6653
  • Oct 24 21:55
    kwonoj commented #6653
  • Oct 24 21:54
    kwonoj labeled #6653
  • Oct 24 21:54
    kwonoj commented #6653
  • Oct 24 19:28
    jakovljevic-mladen synchronize #6635
  • Oct 24 13:33
    lamisChebbi opened #6653
  • Oct 24 12:08
    sagrawal31 opened #6652
  • Oct 21 17:24
    kwonoj closed #6651
  • Oct 21 17:24
    kwonoj commented #6651
  • Oct 21 17:00
    jzabinski-dolios opened #6651
  • Oct 21 09:22
    jakovljevic-mladen commented #6548
  • Oct 21 08:25
    jakovljevic-mladen commented #6391
  • Oct 21 07:53
    jakovljevic-mladen edited #6627
  • Oct 21 07:51
    jakovljevic-mladen commented #6635
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:
Rostero
@rostero1
this works, but is there a clearer way to do this: https://gist.github.com/rostero1/94b86bb1b154ae4b2211f2e00e4b0e0a?
the action tap and ignoreElements is what i'm looking to change
Rostero
@rostero1
maybe it's clear enough. idk actually
Dorus
@Dorus

@rostero1 I'm guessing all you want to do is register the

action$.pipe(
        filter(({ type }) => machine.handles(type)),
        tap(action => {
          service.send(action);
        })

as part of the unsubscribe chain?
Another way to do this would be to make a new observable:

return new Observable(ob => {
  let sub = state$.subscribe(ob);

  let sub2 = action$.pipe(
        filter(({ type }) => machine.handles(type)))
        subscribe(action => {
          service.send(action);
        })

  sub.add(sub2);

  return sub;
})

I leave it to you to decide if this code is any cleaner. I dont think your original is all that bad.

Dorus
@Dorus
(ps. my code samples replaces line 14-23 in yours)
Oleksandr
@kievsash
Hi, everyone. Just composed helper for mocking time-spreaded value emissions range. Maybe someone is interested:

timeRange(range, isRelative = false) => {
const obsArray = http://range.map(item => of(item.value).pipe.delay(item.delay);

return isRelative ? concat(...obsArray) : merge(...obsArray)
}

// usage
timeRange([
{value: 15, delay: 1500}, // 1500ms
{value: 15, delay: 2500} // 2500ms
])

timeRange([
{value: 15, delay: 1500}, // 1500ms
{value: 15, delay: 2500} // 1500+2500
], true)

Dorus
@Dorus
@kievsash can you put it in a code block? Like
```ts
[code]
```