You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.8 KiB

2 years ago
import AppsStore from './../stores/apps.js'
/**
* handler for apps
*
* @author Björn Hase
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3
* @link https://gitea.node001.net/HerrHase/potato-launcher.git
2 years ago
*
*/
class AppsHandler {
/**
* use create in appStore and send event with result to app
*
* @param {object} data
* @return {object}
*
*/
create(connector, data) {
const appsStore = new AppsStore()
appsStore.create(data)
.then((data) => {
connector.send('pouchdb.apps.success', data)
})
}
/**
* use update in appStore and send event with result to app
*
* @param {object} data
* @return {object}
*
*/
update(connector, data) {
const appsStore = new AppsStore()
appsStore.update(data)
.then((data) => {
connector.send('pouchdb.apps.success', data)
})
}
/**
* use update in appStore and send event with result to app
*
* @param {object} data
* @return {object}
*
*/
findOne(connector, data) {
const appsStore = new AppsStore()
appsStore.findOneById(data.id)
.then((data) => {
if (data) {
connector.send('pouchdb.apps.readyOne', data)
}
2 years ago
})
}
/**
* use find in appStore and send event with result to app
*
* @param {object} connector
* @param {object} data
*
*/
find(connector, data) {
const appsStore = new AppsStore()
appsStore.find()
.then((data) => {
console.error('send result', data)
2 years ago
connector.send('pouchdb.apps.ready', data)
})
}
}
export default AppsHandler