Git Product home page Git Product logo

Comments (4)

taras avatar taras commented on July 17, 2024

This sounds like a nice simplification.

from effection.

cowboyd avatar cowboyd commented on July 17, 2024

The one difficulty is that it is annoying to have to save the back reference to Subscription when creating it by hand:

let subscription = {
  *next() {
     // implement next
  },
  *[Symbol.iterator]() { return subscription; },
};
return subscription;

Perhaps we can make a helper "createSubscription()" that helps you do it my just accepting the content of next:

createSubscription(function* next() {
  // implementation of next operation.
});

So for example, the implementation of Subscription in Channel would be something like:

subscription: createSubscription(function* next() {
  let message = items.pop();
  if (message) {
    return message;
  } else {
    return yield* action<Item>(function* (resolve) {
       consumers.unshift(resolve);
    });
  }
}),

Thus far, it has been extremely rare to create subscriptions by hand, since most of the time, I just end up using Channel for lower level ops.

from effection.

cowboyd avatar cowboyd commented on July 17, 2024

I'm going to advocate that we first disambiguate streams from subscriptions (you should never need to deal with a subscription directly) and then we can add make subscriptions streamable individually which will be possible if they have separate API.

from effection.

cowboyd avatar cowboyd commented on July 17, 2024

Closed by #696

from effection.

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.