Giter Club home page Giter Club logo

Comments (4)

ziedmahdi avatar ziedmahdi commented on August 14, 2024 1

so in related docs

// Sometimes publish a query, sometimes publish nothing.
Meteor.publish('secretData', function () {
  if (this.userId === 'superuser') {
    return SecretData.find();
  } else {
    // Declare that no data is being published. If you leave this line out,
    // Meteor will never consider the subscription ready because it thinks
    // you're using the `added/changed/removed` interface where you have to
    // explicitly call `this.ready`.
    return [];
  }
});

so a publication can return an empty array.
Also, stopping a publication (this.stop()) is not same as marking it as ready (this.ready()).

from meteor-publication-collector.

nkahnfr avatar nkahnfr commented on August 14, 2024

Hi,

The error is expected as you must only return a cursor or an array of cursors (see related Meteor documentation).

You can fix your code by replacing the elsestatement with the following:

} else {
    this.ready();
    return;
}

You can even omit the return; statement.

from meteor-publication-collector.

nkahnfr avatar nkahnfr commented on August 14, 2024

@ziedmahdi OK, I checked the source code and an empty array should indeed be supported as a return value for a publication. Basically it should only state that the publication is ready.

That said, IMHO your PR is still incorrect due to this.ready(); having been moved outside the if statement dealing with publications that return cursors.

I will work on a PR that will fix the empty array use-case without breaking the low-level interface one.

from meteor-publication-collector.

nkahnfr avatar nkahnfr commented on August 14, 2024

@ziedmahdi Let me know if that PR does not work in your case.

@johanbrook Let me know if you need more details.

from meteor-publication-collector.

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.