Comparing version 0.0.48 to 0.0.49
33
index.js
@@ -12,11 +12,4 @@ import axios from 'axios' | ||
let evt = new EventEmitter() | ||
App.addListener('appStateChange', ({ isActive }) => { | ||
console.log('App state changed. Is active?', isActive) | ||
if (isActive && safList.length > 0) | ||
processSAF() | ||
}) | ||
if (safList.length > 0) { | ||
evt.emit('onNewPendingTask', safList.length) | ||
} | ||
const api = { | ||
@@ -68,6 +61,14 @@ init: (cfg) => { | ||
const status = netSt.connectionType | ||
if (status === 'wifi' || status === 'cellular' || !status) { | ||
if ((status === 'wifi' || status === 'cellular' || !status) && (safList.length > 0)) { | ||
processSAF() | ||
} | ||
}) | ||
App.addListener('appStateChange', ({ isActive }) => { | ||
console.log('App state changed. Is active?', isActive) | ||
if (isActive && safList.length > 0) | ||
processSAF() | ||
}) | ||
if (safList.length > 0) { | ||
evt.emit('onNewPendingTask', safList.length) | ||
} | ||
}, | ||
@@ -140,11 +141,9 @@ async setHeaders (headers) { | ||
async function processSAF () { | ||
console.log('safList:', safList) | ||
if (safList.length > 0) { | ||
for (const elem of safList) { | ||
await api.callSrv(elem.method, elem.path, elem.params) | ||
} | ||
safList = [] | ||
localStorage.safList = [] | ||
evt.emit('onSAFCompleted') | ||
console.log('safList:', JSON.stringify(safList)) | ||
for (const elem of safList) { | ||
await api.callSrv(elem.method, elem.path, elem.params) | ||
} | ||
safList = [] | ||
localStorage.safList = [] | ||
evt.emit('onSAFCompleted') | ||
evt.emit('onNewPendingTask', safList.length) | ||
@@ -151,0 +150,0 @@ } |
{ | ||
"name": "fwk-api", | ||
"version": "0.0.48", | ||
"version": "0.0.49", | ||
"description": "Framework with api services access(only javascript)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
5383
146