Giter VIP home page Giter VIP logo

Comments (3)

franciscotln avatar franciscotln commented on June 14, 2024 2

Adding a flag to break the while loop solved it (fromIter):

  function loop() {
    inloop = true;
    while (got1) {
      if (finished) break;
      got1 = false;
      res = iterator.next();
      if (res.done) {
        sink(2);
        finished = true;
      } else sink(1, res.value);
    }
    inloop = false;
  }

from callbag.

franciscotln avatar franciscotln commented on June 14, 2024 1

I'm not sure, but I believe the problem is in the done function:

} else if (type === 2) {
  operation();
  sink(type, data);
}

Try adding the sink(type, data) after the call to operation() and try again. You are not letting the sink know that the source finished, so the sink is talking back, asking for data.

EDIT: no that's not the problem, although you should definitely let the sink know about type: 2.
The problem is that when you start emitting what you stored in the array the sink talks back 1. You emit the last element of the array, the talkback asks for more data and the fromIter() sends 2 downwards again. That's why you're getting done() twice.
I'm not sure how to fix this, though.
It's a problem in the fromIter I guess, @staltz
Perhaps a flag "finished" is necessary to prevent the loop again.

from callbag.

staltz avatar staltz commented on June 14, 2024

Thanks! Can anyone think of a test case for callbag-from-iter?

from callbag.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.