You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** The api module for the pouchdb callback pattern */
module callback{/** The main pouchDB interface (callback pattern) */interfacePouchDBextendsapi.db.Callback{}}/** The api module for the pouchdb promise pattern */
module promise{/** The main pouchDB interface (promise pattern) */interfacePouchDBextendsapi.db.Promisable{}}/** The api module for the pouchdb promise pattern (constructor only) */
module thenable{/** * Special case class returned by the constructors of the promise api pouchDB. * Usually only a `pouchdb.promise.PouchDB` reference would be kept, assigned by * the `then` of the constructor. */interfacePouchDBextendspromise.PouchDB,async.Thenable<promise.PouchDB>{}}
thenable.PouchDB is a bad name (a real thenable does not have a catch anyway)
thenable.PouchDB is just there to be the return type for the promise-based constructors (i.e. to prevent then showing up on your pouchdb db variable)
promise.PouchDB is exactly an api.db.Promisable
but pouchdb.promise.PouchDB is there because, ideally, you would be able to do var db : pouchdb.PouchDB. However we are splitting callable and promise interfaces to help end-users, so var db : pouchdb.promise.PouchDB is seemed marginally more explanatory (and has one less level of nesting) than var db : pouchdb.api.db.Promisable
@fredgalvao commented, rightly, that this structure is confusing. So ... how can we improve it?
Option 3 might be the best option. module db is a little superfluous - I only put it there to be clear where the main db interfaces were defined, but then ended up needing the callback and promise modules which are only there to improve the external naming.
Relates to #22
Consider:
thenable.PouchDBis a bad name (a realthenabledoes not have acatchanyway)thenable.PouchDBis just there to be the return type for the promise-based constructors (i.e. to preventthenshowing up on your pouchdbdbvariable)promise.PouchDBis exactly anapi.db.Promisablepouchdb.promise.PouchDBis there because, ideally, you would be able to dovar db : pouchdb.PouchDB. However we are splitting callable and promise interfaces to help end-users, sovar db : pouchdb.promise.PouchDBis seemed marginally more explanatory (and has one less level of nesting) thanvar db : pouchdb.api.db.Promisable@fredgalvao commented, rightly, that this structure is confusing. So ... how can we improve it?
Suggestions:
module promisetomodule promisablein keeping with RenamePromiseinterfaces #22.module thenabletomodule promisableand removemodule promise.module dband use those instead ofmodule callbackandmodule promiseI personally don't like this (which would be a vote against option 2):
compared to
Purely because
dbpis aPouchDB, not aPromisableOption 3 might be the best option.
module dbis a little superfluous - I only put it there to be clear where the main db interfaces were defined, but then ended up needing thecallbackandpromisemodules which are only there to improve the external naming.