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

inconsistency between .of and .fromPromise #282

Closed
ftaiolivista opened this issue Jun 10, 2019 · 1 comment
Closed

inconsistency between .of and .fromPromise #282

ftaiolivista opened this issue Jun 10, 2019 · 1 comment

Comments

@ftaiolivista
Copy link

ftaiolivista commented Jun 10, 2019

Let's try this code.

import xs from 'xstream'


// TEST FROM xs.of()
const a = xs.of(' -a- ').debug(' -a- ')

const b = a.map(v => v + ' -b- ').debug(' -b- ')

const c = a.map(v => v + ' -c- ').debug(' -c- ')

const d = xs
    .merge(b, c)
    .map(v => v + ' -d- ')
    .debug(' -d- ')

d.addListener({
    next: () => {},
    error: () => {},
    complete: () => {}
})

// SAME CODE BUT WITH xs.fromPromise()
const a2 = xs.fromPromise(Promise.resolve(' -a- ')).debug(' -a2- ')

const b2 = a2.map(v => v + ' -b2- ').debug(' -b2- ')

const c2 = a2.map(v => v + ' -c2- ').debug(' -c2- ')

const d2 = xs
    .merge(b2, c2)
    .map(v => v + ' -d2- ')
    .debug(' -d2- ')

d2.addListener({
    next: () => {},
    error: () => {},
    complete: () => {}
})

The debug output is like
a-b-d-a-c-d
a2-b2-d2-c2-d2

Why when create the stream from promise the first debug is printed only one time at the beginning and when create it with .of() from const value the debug 'a' is printed two time?

P.S. Related stack overflow question

@ftaiolivista
Copy link
Author

see #283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant