cleanup + docs...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-09-02 21:27:17 +03:00
parent 463eb0918a
commit 7863efebb8

View File

@ -138,7 +138,6 @@ var CollectionActions = actions.Actions({
// ... // ...
// } // }
// //
// XXX should these get auto-sorted???
get collection_handlers(){ get collection_handlers(){
var handlers = this.__collection_handlers = this.__collection_handlers || {} var handlers = this.__collection_handlers = this.__collection_handlers || {}
@ -161,28 +160,6 @@ var CollectionActions = actions.Actions({
return handlers return handlers
}, },
/*/ XXX do we actually need this????
collectionDataLoader: ['- Collections/',
core.doc`Collection data loader
.collectionDataLoader(title, data)
-> promise
The resulting promise will resolve to a Data object that will get
loaded as the collection.
data is of the .collections item format.
This will not clone .data, this all changes made to it are
persistent.
`,
{collectionFormat: 'data'},
function(title, data){
return new Promise(function(resolve){ resolve(data.data) }) }],
//*/
// XXX revise loader protocol...
// ...should it be cooperative???
loadCollection: ['- Collections/', loadCollection: ['- Collections/',
core.doc`Load collection... core.doc`Load collection...
@ -203,8 +180,18 @@ var CollectionActions = actions.Actions({
- only the first matching handler is called - only the first matching handler is called
- the data handler is always first to get checked - the data handler is always first to get checked
For an example handler see: Example loader action:
.collectionDataLoader(..) collectionXLoader: [
// handle .x
{collectionFormat: 'x'}
function(title, state){
return new Promise(function(resolve){
var x = state.x
// do stuff with .x
resolve()
}) }],
The .data handler is always first to enable caching, i.e. once some The .data handler is always first to enable caching, i.e. once some
@ -689,11 +676,10 @@ var CollectionActions = actions.Actions({
var state = collections[title] var state = collections[title]
var s = res.collections[title] = { title: title }
var data = ((mode == 'base' && state.crop_stack) ? var data = ((mode == 'base' && state.crop_stack) ?
(state.crop_stack[0] || state.data) (state.crop_stack[0] || state.data)
: state.data) : state.data)
var s = res.collections[title] = { title: title }
if(data){ if(data){
s.data = data.dumpJSON() s.data = data.dumpJSON()
} }
@ -1053,7 +1039,7 @@ var AutoTagCollectionsActions = actions.Actions({
// remove unmatching... // remove unmatching...
.clear(remove) .clear(remove)
resolve(state.data) resolve()
}).bind(this)) }], }).bind(this)) }],
}) })