Commit 8f841374 authored by Chris Scott's avatar Chris Scott

Add hash-merge method used in setConfig for handy access to config params plugin is configured with

parent d982599f
...@@ -10,7 +10,7 @@ module.exports = { ...@@ -10,7 +10,7 @@ module.exports = {
config: {}, config: {},
configure: function(success, failure, config) { configure: function(success, failure, config) {
this.config = config || {}; this.config = config;
var params = JSON.stringify(config.params || {}), var params = JSON.stringify(config.params || {}),
headers = JSON.stringify(config.headers || {}), headers = JSON.stringify(config.headers || {}),
url = config.url || 'BackgroundGeoLocation_url', url = config.url || 'BackgroundGeoLocation_url',
...@@ -65,7 +65,7 @@ module.exports = { ...@@ -65,7 +65,7 @@ module.exports = {
* @param {Integer} timeout * @param {Integer} timeout
*/ */
setConfig: function(success, failure, config) { setConfig: function(success, failure, config) {
this.config = config || {}; this.apply(this.config, config);
exec(success || function() {}, exec(success || function() {},
failure || function() {}, failure || function() {},
'BackgroundGeoLocation', 'BackgroundGeoLocation',
...@@ -82,6 +82,11 @@ module.exports = { ...@@ -82,6 +82,11 @@ module.exports = {
'getStationaryLocation', 'getStationaryLocation',
[]); []);
}, },
/**
* Add a stationary-region listener. Whenever the devices enters "stationary-mode", your #success callback will be executed with #location param containing #radius of region
* @param {Function} success
* @param {Function} failure [optional] NOT IMPLEMENTED
*/
onStationary: function(success, failure) { onStationary: function(success, failure) {
var me = this; var me = this;
success = success || function() {}; success = success || function() {};
...@@ -94,5 +99,14 @@ module.exports = { ...@@ -94,5 +99,14 @@ module.exports = {
'BackgroundGeoLocation', 'BackgroundGeoLocation',
'addStationaryRegionListener', 'addStationaryRegionListener',
[]); []);
},
apply: function(destination, source) {
source = source || {};
for (var property in source) {
if (source.hasOwnProperty(property)) {
destination[property] = source[property];
}
}
return destination;
} }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment