Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin api #1387

Closed
calvinmetcalf opened this issue Feb 12, 2014 · 5 comments
Closed

plugin api #1387

calvinmetcalf opened this issue Feb 12, 2014 · 5 comments

Comments

@calvinmetcalf
Copy link
Member

currently the api is "string we never use", constructor and all the methods on the returned object get merged. Something more like "method name", constructor might be better

//old
PouchDD.plugin("mapreduce",constructor);
//idea
PouchDB.plugin("query",constructor);

a third argument could be the name of the export method

@jo
Copy link
Member

jo commented Feb 12, 2014

Using the id string allows to overwrite a plugin, eg by providing a different mapreduce plugin - but I'm also unhappy with those otherwise useless strings.

And, while we're at it (and motivated by the generality of this ticket):
It would be so nice if it's possible to hook into document read and write, empowering sort of transform plugins.
Such a plugin could add timestamps for example, parse dates and so on.

With our current plugin system this is not possible because they are exclusively, meaning the last installed plugin provides the method. Maybe the plugin could just receive the old api?

@calvinmetcalf
Copy link
Member Author

Well specifying the name of the method (IE query instead of MapReduce)
would have the same results, pre and post hooks would be nice, might
necessitate changing the httpadapter to use the underscore methods like
the other ones
On Feb 12, 2014 11:19 AM, "Johannes Jörg Schmidt" [email protected]
wrote:

Using the id string allows to overwrite a plugin, eg by providing a
different mapreduce plugin - but I'm also unhappy with those otherwise
useless strings.

And, while we're at it (and motivated by the generality of this ticket):
It would be so nice if it's possible to hook into document read and write,
empowering sort of transform plugins.
Such a plugin could add timestamps for example, parse dates and so on.

With our current plugin system this is not possible because they are
exclusively, meaning the last installed plugin provides the method. Maybe
the plugin could just receive the old api?


Reply to this email directly or view it on GitHubhttps://github.com/daleharvey/pouchdb/issues/1387#issuecomment-34884939
.

@jo
Copy link
Member

jo commented Feb 12, 2014

yes, thats right.

Shouldn't it be possible to specify more than one method?

// eg
PouchDB.plugin(constructor, ["query", "find"]);
// or
PouchDB.plugin(constructor, "query", "find");

@nolanlawson
Copy link
Member

While we're at it, #1118 is still a low-hanging fruit. Would probably really help with all the goodfirstpatch/goodstudentproject stuff.

@calvinmetcalf
Copy link
Member Author

so now that the prototype one landed, we could have a new style plugin, which we just add to PouchDB.prototype

calvinmetcalf added a commit that referenced this issue Mar 8, 2014
(#1387) - prototype based plugins api
sygi pushed a commit to sygi/pouchdb that referenced this issue Apr 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants