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

Possible issue with laziness #9

Open
devinivy opened this issue Feb 28, 2021 · 0 comments
Open

Possible issue with laziness #9

devinivy opened this issue Feb 28, 2021 · 0 comments

Comments

@devinivy
Copy link

devinivy commented Feb 28, 2021

First, thanks for pull-streams— truly a treat :)

I attempted to implement a deferred source using pull-many. It looks like this:

function defer () {
  const deferred = many()
  return Object.assign(deferred, {
    resolve (stream) {
      deferred.add(stream)
      deferred.cap()
    }
  })
}

This works, however I find that the resolved stream is eagerly pulled even if there's no sink. Here's an example:

const deferred = defer()
deferred.resolve(pull(pull.once('x'), pull.through(console.log)))
// I would expect no output since there is no sink, but instead 'x' is logged

Does this behavior seem intentional or might there be something to dig into here? My workaround is simply to use pull-defer, which preserves laziness in the way I originally expected. If you believe there's an issue here, I would be happy to look into contributing a fix.

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