Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nothing is received from DOM source until something is emitted on DOM sink. #791

Closed
rmeoc opened this issue Mar 20, 2018 · 0 comments · Fixed by #793
Closed

Nothing is received from DOM source until something is emitted on DOM sink. #791

rmeoc opened this issue Mar 20, 2018 · 0 comments · Fixed by #793

Comments

@rmeoc
Copy link
Contributor

rmeoc commented Mar 20, 2018

Code to reproduce the issue:
https://jsbin.com/kopipeceru/1/edit?html,js,console,output

const xs = xstream.default;
const { run } = Cycle;
const { makeDOMDriver } = CycleDOM;

function main(sources) {

    sources.DOM.elements().addListener({
      next: i => console.log('elements: ' + i),
      error: err => console.error('elements, error: ' + err),
      complete: () => console.log('elements: complete'),
    });

    sources.DOM.events('click').addListener({
      next: i => console.log('click: ' + i),
      error: err => console.error('click, error: ' + err),
      complete: () => console.log('click: complete'),
    });

  return {
        DOM: xs.never()
    };
}

const drivers = {
    DOM: makeDOMDriver('#app')
};

run(main, drivers);

Expected behavior:
Until something is emitted on the DOM sink, the streams returned by the DOM source emit the elements and events for the initial state of the DOM.
For the example code this means that:

  • when loading the page, "elements: [object HTMLDivElement]" is sent to the console
  • when clicking on the button, "click: [object MouseEvent]" is sent to the console

Actual behavior:
Until something is emitted on the DOM sink, the streams returned by the DOM source do not emit anything.
For the example code this means that loading the page or clicking on the button does not result in console messages

Versions of packages used:

  • xstream 11.2.0
  • @cycle/dom 20.2.0 (issue was introduced with cycle/dom 20.0.0)
  • @cycle/run 4.1.0
rmeoc added a commit to rmeoc/cyclejs that referenced this issue Mar 25, 2018
The elementAfterPath$ stream was immediately sampled, while elementAfterPath$ only starts emitting
once the DOM is ready, causing the first emission of elementAfterPath$ to be missed. By postponing
the first sample of elementAfterPath$ until the DOM is ready, we make sure that we don't miss this
first emission.

ISSUES CLOSED: cyclejs#791
rmeoc added a commit to rmeoc/cyclejs that referenced this issue Mar 26, 2018
…ementAfterPath$ stream was immediately sampled, while elementAfterPath$ only starts emittingonce the DOM is ready, causing the first emission of elementAfterPath$ to be missed. By postponingthe first sample of elementAfterPath$ until the DOM is ready, we make sure that we don't miss thisfirst emission.ISSUES CLOSED: cyclejs#791
rmeoc added a commit to rmeoc/cyclejs that referenced this issue Mar 26, 2018
The elementAfterPath$ stream was immediately sampled, while elementAfterPath$ only starts emitting
once the DOM is ready, causing the first emission of elementAfterPath$ to be missed. By postponing
the first sample of elementAfterPath$ until the DOM is ready, we make sure that we don't miss this
first emission.

ISSUES CLOSED: cyclejs#791
staltz pushed a commit that referenced this issue May 4, 2018
The elementAfterPath$ stream was immediately sampled, while elementAfterPath$ only starts emitting
once the DOM is ready, causing the first emission of elementAfterPath$ to be missed. By postponing
the first sample of elementAfterPath$ until the DOM is ready, we make sure that we don't miss this
first emission.

ISSUES CLOSED: #791
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants