From 118c2414022bc97cdfdf299a1f490d7d4a5d3145 Mon Sep 17 00:00:00 2001 From: pawlaczyk Date: Tue, 8 Jan 2019 17:29:11 +0100 Subject: [PATCH] refaktoryzacja promise vueObj --- frontend/app/src/views/Cards.vue | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/frontend/app/src/views/Cards.vue b/frontend/app/src/views/Cards.vue index f996942..ab8ca70 100644 --- a/frontend/app/src/views/Cards.vue +++ b/frontend/app/src/views/Cards.vue @@ -73,13 +73,13 @@ export default { daneZbazy(){ // w linii komend jako admin na Windzie w folderze app // C:\Users\dp\Desktop\PracowaniaProgramowania\frontend\app>add-cors-to-couchdb http://127.0.0.1:5984 -u root -p password success - var mojeVue = this; + var objectVue = this; var db = new PouchDB('http://localhost:5984/golang_cards'); var cardsTmp = [] db.allDocs({include_docs : true}).then(function (res) { - mojeVue.totalRows = res.total_rows; //aktualizacja zmiennej majacej liczbe wierszy + objectVue.totalRows = res.total_rows; //aktualizacja zmiennej majacej liczbe wierszy res.rows.forEach(function (entry){ var tmp = {} @@ -99,7 +99,7 @@ export default { this.cards = cardsTmp }, checkDiference(){ - var mojeVue = this; + var objectVue = this; //Sprawdza róznice w bazie danych - czy nie zostały dodane nowe dane var db = new PouchDB('http://localhost:5984/golang_cards'); @@ -120,19 +120,16 @@ export default { }) //wywolanie magii - var proszeDzialaj = promiseRows.then(function(fromResolve){ - return fromResolve + promiseRows.then(function(fromResolve){ + if (fromResolve !== objectVue.totalRows){ //javascriptowe fantastyczne porownania + //aktualizuj dane wyswietlane + objectVue.daneZbazy() + console.log("Nowe dane") + } }).catch(function(fromReject){ return "Proszę nie :<" }) - proszeDzialaj.then(function(fromResolve){ - if (fromResolve !== mojeVue.totalRows){ //javascriptowe fantastyczne porownania - //aktualizuj dane wyswietlane - mojeVue.daneZbazy() - console.log("Nowe dane") - } - }) } },