Skip to content

Possible issue with laziness #9

Description

@devinivy

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions