Comments (3)
@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.
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.
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)
- Extend Ground.Collection HOT 1
- [warning] mutating the [[Prototype]] of an object will cause your code to run very slowly HOT 2
- Interesting HOT 2
- `Meteor.addCollectionExtension` is deprecated HOT 16
- Mutating the Prototype of an object cause your code to run very slowly lai_collection-extensions.js:97:5 HOT 1
- meteor 1.6.1 ? HOT 3
- Updating dependencies HOT 1
- update atmosphere package? HOT 1
- Using CollectionExtensions instead of Meteor? HOT 5
- Update README on mongo-collection-instances HOT 2
- Figure out how to Meteor.users instanceof Mongo.Collection
- Meteor.Collection !== Meteor.Collection.prototype.constructor HOT 2
- zimme:collection-behaviours HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-collection-extensions.