Skip to content

Commit

Permalink
Merge branch 'common-src' into master-src: deleteDatabase reliability (
Browse files Browse the repository at this point in the history
…#112); open & close callbacks (#109/#110)
  • Loading branch information
Chris Brody committed Aug 21, 2014
2 parents b5b5104 + 06cf43e commit ab9bc50
Show file tree
Hide file tree
Showing 6 changed files with 609 additions and 251 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.DS_Store
.plugin
.metadata/*
*.swp
*~
20 changes: 17 additions & 3 deletions SQLitePlugin.coffee.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@ License for common Javascript: MIT or Apache
return
SQLitePlugin::transaction = (fn, error, success) ->
if !@openDBs[@dbname]
error('database not open')
return
@addTransaction new SQLitePluginTransaction(this, fn, error, success, true, false)
return
SQLitePlugin::readTransaction = (fn, error, success) ->
if !@openDBs[@dbname]
error('database not open')
return
@addTransaction new SQLitePluginTransaction(this, fn, error, success, true, true)
return
Expand All @@ -105,10 +111,17 @@ License for common Javascript: MIT or Apache
return
SQLitePlugin::open = (success, error) ->
onSuccess = () => success this
unless @dbname of @openDBs
@openDBs[@dbname] = true
cordova.exec success, error, "SQLitePlugin", "open", [ @openargs ]
cordova.exec onSuccess, error, "SQLitePlugin", "open", [ @openargs ]
else
###
for a re-open run onSuccess async so that the openDatabase return value
can be used in the success handler as an alternative to the handler's
db argument
###
nextTick () -> onSuccess();
return
SQLitePlugin::close = (success, error) ->
Expand All @@ -117,7 +130,7 @@ License for common Javascript: MIT or Apache
if @dbname of @openDBs
delete @openDBs[@dbname]
cordova.exec null, null, "SQLitePlugin", "close", [ { path: @dbname } ]
cordova.exec success, error, "SQLitePlugin", "close", [ { path: @dbname } ]
return
Expand Down Expand Up @@ -381,6 +394,7 @@ License for common Javascript: MIT or Apache
new SQLitePlugin openargs, okcb, errorcb
deleteDb: (databaseName, success, error) ->
delete SQLitePlugin::openDBs[databaseName]
cordova.exec success, error, "SQLitePlugin", "delete", [{ path: databaseName }]
### Exported API:
Expand Down
2 changes: 1 addition & 1 deletion bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fi

if [[ ! -x $(which cordova) ]]; then
echo "you need cordova. please install with:"
echo "npm install -g coffee-script"
echo "npm install -g cordova"
exit 1
fi

Expand Down
Loading

0 comments on commit ab9bc50

Please sign in to comment.