Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 07 20:08

    dependabot[bot] on npm_and_yarn

    (compare)

  • May 07 20:08

    staltz on master

    chore(deps): bump ini from 1.3.… (compare)

  • May 07 20:08
    staltz closed #322
  • May 07 19:58

    dependabot[bot] on npm_and_yarn

    (compare)

  • May 07 19:58

    staltz on master

    chore(deps): bump hosted-git-in… (compare)

  • May 07 19:58
    staltz closed #321
  • May 07 19:47

    dependabot[bot] on npm_and_yarn

    (compare)

  • May 07 19:47
    dependabot[bot] closed #318
  • May 07 19:47
    dependabot[bot] commented #318
  • May 07 19:47
    dependabot[bot] labeled #322
  • May 07 19:47
    dependabot[bot] opened #322
  • May 07 19:47

    dependabot[bot] on npm_and_yarn

    chore(deps): bump ini from 1.3.… (compare)

  • May 07 19:47
    dependabot[bot] edited #318
  • May 07 19:46
    dependabot[bot] labeled #321
  • May 07 19:46
    dependabot[bot] opened #321
  • May 07 19:46

    dependabot[bot] on npm_and_yarn

    chore(deps): bump hosted-git-in… (compare)

  • May 07 19:46
    dependabot[bot] edited #318
  • May 07 19:45

    staltz on npm_and_yarn

    (compare)

  • May 07 19:45

    staltz on master

    chore(deps): bump handlebars fr… (compare)

  • May 07 19:45
    staltz closed #320
André Staltz
@staltz
cyclejs/cyclejs#365
Nikhil Tilwalli
@ntilwalli
@staltz Am I right that your example has varying behavior in xstream but not in RxJS?
By my understanding since xstream does an async unsubscribe (under the hood) during flatten the new subscriber will be added before the old one is removed ensuring the sum$ never goes down to zero subscribers, thus causing it to never reset. RxJS does synchronous unsubscribe during switchMap thus in RxJS the sum$ would go from one down to zero subscribers temporarily before immediately adding the new subscriber and going from zero back to one subscriber (resetting it). The reset from zero subscribers would happen in either version of the code...
Nikhil Tilwalli
@ntilwalli
The unicast/multicast referential transparency issue is exposed when sum$ has subscribers other than lastSum$. No matter the lib, xstream or RxJS, in the sum$ example, the number of subscribers will never go down to zero so the stream will never get reset, whereas in the commented-out version a new stream reference (with zero existing subscribers) is created on every refresh$ emission...
André Staltz
@staltz
@ntilwalli did you test that in RxJS? I don't think RxJS would have this issue becaues xstream does sync-start, async-stop, so when switching to the same inner stream as the previous, in xstream no unsubscribe of the inner will happen
in RxJS, switchMap does sync-start, sync-stop, so it will unsubscribe
furthermore, there's no multicasting and refcounting in RxJS's sum$ in that example, unless you explicitly choose it
Nikhil Tilwalli
@ntilwalli
I thought that's what I said. In RxJS the subscriber count will go down to zero so the stream will reset, in xstream the subscriber count will not go down to zero, so the stream will not reset
The variance comes from whether the stream resets or not...
In RxJS it will reset regardless of whether a stream reference is reused or not. In xstream reusing the reference causes the stream to not reset...
Nikhil Tilwalli
@ntilwalli
You reminded me of the referential transparency issue which I'd forgotten about. :) I was just pointing out that if you add an additional subscriber, the example (which right now only exposes the issue in xstream) would also demonstrate the issue in RxJS
André Staltz
@staltz
Nikhil, you mean with multicasting in RxJS, right? Just want to clarify that "subscriber count" only exists with subjects and with refCounting
Nikhil Tilwalli
@ntilwalli
Yes, that's what I meant. Agreed :thumbsup:
Steve Lee
@SteveALee
can see in node_modules, node_modules\cycle-restart\node_modules and node_modules\cyclejs-test-helpers\node_modules
is tree shaking enabled and working now?
oops, wrong convo!
Вячеслав Истомин
@shofel

It looks like xs.of() is the same as 'xs.empty()'.
I was expecting xs.of() equals to xs.of(null) or somewhat. Now I see the actual behaviour does make sense, but at first it's not as obvious.

Maybe we should mention this in the description of xs.of? I mean, equivalence of xs.of() without args and xs.empty().

André Staltz
@staltz
Hi @shofel, I think xs.of() should be the same as xs.of(undefined), so it's not the same as xs.empty()
Вячеслав Истомин
@shofel

@staltz, my intuition was the same as you wrote.

As for now, xs.of() and xs.of(undefined) behave differently.

xs.of() completes immediately, not emmiting anything. (|)

But xs.of(undefined) emits undefined and completes immediately. (undefined|)

https://runkit.com/59c12300c3b4c40012a5260e/59c1230162f5730012fd3b86

André Staltz
@staltz
oh, correct! the args in function of(...args) is empty array
you were right
Alex
@whitecolor
also merge() and combine() are the same as empty() =)
Serge Havas
@Sinewyk
Hey, when working on cyclejs/cyclejs#736 I was bitten by the fact that streams can start emitting values synchronously. I'm coming from most where they enforced that values should always start emitting asynchronously.
So 1/ For academics reasons: why did you settle that starting to emit values could happen synchronously ? 2/ I think it need to be made clearer around here https://github.com/staltz/xstream#how-a-stream-starts-and-stops or above, that yes, writing this code
console.log(0)
xs.of(1).subscribe({next: n => console.log(n)});
console.log(2);

will yield

0
1
2

and not

0
2
1

As I first believed.

Which means that sometimes you can access the subscription inside the subscribe handlers, and sometimes you can't. Which is super important IMO.
Serge Havas
@Sinewyk
Any idea how to use replaceError with typescript ?
I'm using it to transforms a stream of strings into a stream of errors, but replaceError seem to absolutely want to keep the signature of the stream we are using it on, am I doing something wrong ?
Serge Havas
@Sinewyk
argggggg, again, I got bitten by the fact that event can and will happen synchronously when they can, got to remember that, sprinkling remember() will ensure that even though event happened, subscribing after will still get me where I want
Вячеслав Истомин
@shofel

Hello!

Could anyone suggest how to transform
a stream

0, 1, 2, 3, ...

to

[0, 1], [1, 2], [2, 3], ...
Serge Havas
@Sinewyk
fold + filter I would say
you fold to push events into an array, while limiting the size 1 array by filtering it out
Вячеслав Истомин
@shofel
Yeah, indeed. I've got it. Thank you.
Вячеслав Истомин
@shofel

Just giving back)

  /* *
   * A pair data structure.
   * Like an array but 
   *  - You can only push and get values.
   *  - Its length is never greater than 2. Two the most recently pushed elements.
   */

  /* @util */
  let push = x => xs => {
    let xs_ = xs.slice()
    xs_.push(x)
    return xs_
  }

  let Pair = (values = []) => {
    let pushToPair = x => Pair(push(x)(values).slice(-2))
    return {values, push: pushToPair}
  }

  let refreshPair = (pair, x) => pair.push(x)

  /**
   * Stream operator.
   * 
   * `----1---2-----3-----4--------|`
   * .compose(slidingLastPair)
   * `[]--[1]-[1,2]-[2,3]-[3,4]----|`
   */
  let slidingLastPair = $ =>
    $.fold(refreshPair, Pair())
    .map(prop('values'))

  /**
   * Example
   */

  let pair$ =
    xs.of(1, 2, 3, 4)
    .compose(slidingLastPair)

@Sinewyk, what do you think is a better name for this operator?

Serge Havas
@Sinewyk
Hmm, it seems like a sliding window more generally, but what you have is good
I would just use more ramda :laughing:
André Staltz
@staltz
I think we already have an operator for that: pairwise
it's an extra operator
Marco Toniut
@marcotoniut

@marcotoniut
Hey everyone, I finally managed to pinpoint a bug my program had to this localized piece of code

test('combine', t => {
    const s$ = Stream.of(Stream.of(1), Stream.of(2), Stream.of(3))
        .map(x => x.remember())
        .fold((acc: Stream<number>[], x: Stream<number>) => [...acc, x], [] as Stream<number>[]).debug('collection')
        .map(ss => combine(...ss)).flatten().debug('combined');
    // return s$.take(1).map(x => t.deepEqual(x, []));
    // return s$.last().map(x => t.deepEqual(x, [1, 2, 3]));
    return combine(s$.take(1), s$.last()).map(([x, y]) => {
        t.deepEqual(x, []);
        t.deepEqual(y, [1, 2, 3]);
    });
});

From what I can gather, the problem is that after the s$.take(1) stream is travelled, the source streams in combine aren't re-triggering the events for s$.last() to complete
Therefore, the combined s$.take(1) and s$.last() never finishes
Is there a way to prevent this from happening? I thought remember was supposed to re-trigger the event when a new stream was hooked to it

Вячеслав Истомин
@shofel
@staltz, yeah it is! Don't know how could I overlook this))
Alex
@whitecolor
@staltz Say I have: const source = periodic(100); const sA = source.map(x => x*10); const sB = source.map(x => x*20) Is it possible to check if both sA and sB "come" from the same source stream? (maybe using some "private" props)
André Staltz
@staltz
Yes there is
The cycle devtools do that
Through some underscore prefixed properties like _ins
Alex
@whitecolor
So I believe I should recursively traverse s._prod.ins to get to the common source
André Staltz
@staltz
Yes : )
Вячеслав Истомин
@shofel

Have a nice day!

My collegue and I trying to run our cycle.js application on Chrome 49. This is the newest version available for Windows XP.
Windows XP is, of course, a requirement by very old and very big national company :)))

We use babel preset env chrome >= 49, and babel-polyfill.
And it fails at some point somewhere inside Stream with a cryptic error "Illegal invocation."

@staltz Is there any chances to run xstream on Chrome 49,
or there are some known obstacles?

Вячеслав Истомин
@shofel

It appeared, the Yandex browser, which is based on Chromium, had been maintained for longer time than Chrome. And for some reason it works better with our app.

The further, the less it's about the xstream library. But I still curious if there is some feature of browser, which xstream uses, and which some old browsers lack and can not be polyfilled.

Nick Johnstone
@Widdershin
@shofel any chance you could make a minimal reproducer? not too much to go on here
Вячеслав Истомин
@shofel
@Widdershin thanks for consideration! We've decided to be contained with Yandex browser. I believe the issue relates only to some ancient browsers and hence it doesn't worth to be investigated.