question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

combine breaks when passed two streams that share a parent

See original GitHub issue

Here is a runnable reproducer:

import assert from 'assert';
import xs from 'xstream';

function Counter (click$) {
  const count$ = click$
    .fold((total) => total + 1, 0)
    .remember();

  return {
    count$,

    countString$: count$.map(count => count.toString())
  };
}

const click$ = xs.create();

const counter = Counter(click$);

const combinedStreams = xs.combine(
  (...vals) => vals,
  counter.count$,
  counter.countString$
);

const expectedValues = [
  [0, '0'],
  [1, '1']
];

combinedStreams.addListener({
  next(vals) {
    console.log('expected:', expectedValues[0], 'actual:', vals);
    assert.deepEqual(expectedValues.shift(), vals);
  },
  error(err) {
    throw err;
  },
  complete() {}
});

click$.shamefullySendNext();
 $ ./node_modules/.bin/babel-node test.js
expected: [ 0, '0' ] actual: [ 0, '0' ]
expected: [ 1, '1' ] actual: [ 1, '0' ]

AssertionError: [ 1, '1' ] deepEqual [ 1, '0' ]

We expect to see that the count$ and countString$ are equal, but only the count$ increments on click$.

If you pass countString$ as the first stream to combine, the opposite happens.

This use case is important for @cycle/collection, for combining multiple sinks on each item.

I’m unsure if this is a bug, or if I’m just misunderstanding something fundamental.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Widdershincommented, Jun 22, 2016

@ntilwalli I can no longer reproduce this issue in the latest version of xstream, so please consider this issue done and dusted. Thanks for your help 😄

0reactions
ntilwallicommented, Jun 22, 2016

@Widdershin I’m not able to replicate the behavior you describe on webpackbin. If you look here (I posted your exact code but removed the assert) you’ll see the second stream does increment (http://www.webpackbin.com/Nk9ZrTGHb). Can you post a bin which demonstrates the odd behavior?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Combine streams from Firestore in flutter - Stack Overflow
Use CombineLatestStream from rxdart to combine streams. The StreamBuilder will build every time one of the streams emits a new event.
Read more >
Staind - It's Been Awhile (Official Video) - YouTube
The official video for "It's Been Awhile" by Staind from their album ' Break The Cycle' - available now!Pre-order/ stream “It's Been Awhile ......
Read more >
Breaking down CI/CD complexity with parent-child and multi ...
With parent-child pipelines we could break the configurations down into two separate tracks by having two separate jobs trigger child ...
Read more >
Define a Parent Data Stream - Salesforce Help
Define a parent data stream to determine a connection between two data streams ... On the Connect & Mix tab, click Data Streams...
Read more >
Combining 10-Minute Rest Breaks May—or May Not—Be ...
California's nuanced meal and rest break rules have spawned an endless ... that had a practice of combining two daily 10-minute rest breaks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found