mirror of
https://github.com/wekan/wekan.git
synced 2026-01-01 15:18:49 +01:00
adding ReactiveCache to other source code
This commit is contained in:
parent
30d154724a
commit
3f3b4746a9
4 changed files with 184 additions and 17 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { DataCache } from 'meteor-reactive-cache';
|
||||
import { Jsons } from './jsons';
|
||||
|
||||
// Server isn't reactive, so search for the data always.
|
||||
ReactiveCacheServer = {
|
||||
|
|
@ -6,6 +7,30 @@ ReactiveCacheServer = {
|
|||
const ret = Boards.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getList(id) {
|
||||
const ret = Lists.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getSwimlane(id) {
|
||||
const ret = Swimlanes.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getChecklist(id) {
|
||||
const ret = Checklists.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getCard(id) {
|
||||
const ret = Cards.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getCustomField(id) {
|
||||
const ret = CustomFields.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getCustomFields(selector) {
|
||||
const ret = CustomFields.find(selector).fetch();
|
||||
return ret;
|
||||
},
|
||||
}
|
||||
|
||||
// only the Client is reactive
|
||||
|
|
@ -21,6 +46,66 @@ ReactiveCacheClient = {
|
|||
}
|
||||
const ret = this.__board.get(id);
|
||||
return ret;
|
||||
},
|
||||
getList(id) {
|
||||
if (!this.__list) {
|
||||
this.__list = new DataCache(listId => {
|
||||
const _ret = Lists.findOne(listId);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__list.get(id);
|
||||
return ret;
|
||||
},
|
||||
getSwimlane(id) {
|
||||
if (!this.__swimlane) {
|
||||
this.__swimlane = new DataCache(swimlaneId => {
|
||||
const _ret = Swimlanes.findOne(swimlaneId);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__swimlane.get(id);
|
||||
return ret;
|
||||
},
|
||||
getChecklist(id) {
|
||||
if (!this.__checklist) {
|
||||
this.__checklist = new DataCache(checklistId => {
|
||||
const _ret = Checklists.findOne(checklistId);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__checklist.get(id);
|
||||
return ret;
|
||||
},
|
||||
getCard(id) {
|
||||
if (!this.__card) {
|
||||
this.__card = new DataCache(cardId => {
|
||||
const _ret = Cards.findOne(cardId);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__card.get(id);
|
||||
return ret;
|
||||
},
|
||||
getCustomField(id) {
|
||||
if (!this.__customField) {
|
||||
this.__customField = new DataCache(customFieldId => {
|
||||
const _ret = CustomFields.findOne(customFieldId);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__customField.get(id);
|
||||
return ret;
|
||||
},
|
||||
getCustomFields(selector) {
|
||||
if (!this.__customFields) {
|
||||
this.__customFields = new DataCache(sel => {
|
||||
const _ret = CustomFields.find(Jsons.parse(sel)).fetch();
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__customFields.get(Jsons.stringify(selector));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -40,6 +125,60 @@ ReactiveCache = {
|
|||
}
|
||||
return ret;
|
||||
},
|
||||
getList(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getList(id);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getList(id);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getSwimlane(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getSwimlane(id);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getSwimlane(id);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getChecklist(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getChecklist(id);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getChecklist(id);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getCard(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getCard(id);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getCard(id);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getCustomField(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getCustomField(id);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getCustomField(id);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getCustomFields(selector) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getCustomFields(selector);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getCustomFields(selector);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
}
|
||||
|
||||
export { ReactiveCache };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue