GithubHelp home page GithubHelp logo

Comments (3)

rclai avatar rclai commented on May 28, 2024

@matb33, can you elaborate more regarding "allowing users a way to circumvent collections hooks" and "circumventing collection extensions at once"?

What would your ideal API look like for all this?

from meteor-collection-extensions.

matb33 avatar matb33 commented on May 28, 2024

So this is a really good question, and so I had to dig through your code in more detail to try and answer.

Now that I have, I think that perhaps your current incarnation of collection-extensions isn't quite doing enough. It doesn't appear to be taking responsibility for the actual method wrapping, which I think is important to abstract away from any consumer of collection-extensions.

For example, in the collection-hooks fork you made, I see this:

Meteor.addCollectionExtension(function () {
  CollectionHooks.extendCollectionInstance(this, (typeof Mongo !== 'undefined' && typeof Mongo.Collection !== 'undefined' ? Mongo.Collection : Meteor.Collection));
});

I'm saying that collection-extensions should go a bit further than that and actually take over responsibility for pretty much this stuff:

  // Wrap mutator methods, letting the defined advice do the work
  _.each(advices, function (advice, method) {
    // Store a reference to the mutator method in a publicly reachable location
    var _super = collection[method];

    Meteor._ensure(self, "direct", method);
    self.direct[method] = function () {
      var args = arguments;
      return directOp(function () {
        return constructor.prototype[method].apply(self, args);
      });
    };

    collection[method] = function () {

That way we are only wrapping each of the collection methods once, and collection-extensions can offer an API to add/remove/manage the various extensions (collection-hooks being one of them).

Are you following what I'm getting at? Is this deviating too much from what you originally intended? To me this seems like the sweet spot.

from meteor-collection-extensions.

rclai avatar rclai commented on May 28, 2024

Okay, that makes sense, so essentially you'd like for this package to take care of wrapping not just the Mongo.Collection constructor but also its methods? Isn't that essentially going to cause a huge part of your package to become part of this package? I'm referring to the advice code that you have.

I'm trying to figure out how you or anyone else would like to consume this package for things other than hooks.

I think that if you explain how you plan to solve this issue I'll have a better idea of what to do on this end.

As a matter of fact, would it be too much to ask for a PR just to get things started?

from meteor-collection-extensions.

Related Issues (14)

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.