From 75415c9ecc91d0eb90b5eb62ed4bd427f33bfd3a Mon Sep 17 00:00:00 2001 From: Daniel Suchy Date: Tue, 11 Oct 2016 09:44:37 +0200 Subject: [PATCH] Readme updates, dependency update, minor fixes --- README.md | 25 +++++++++++++++++++++---- package.json | 17 ++++++++++------- src/cache.service.ts | 3 --- src/storage.ts | 4 ++++ 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 83c5f5d..83e6b05 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ Key features: + Don't invalidate cache if is browser offline + Set and invalidate groups of entries +TO DO: ++ Add cordova-sqlite-storage plugin support again + Please report all bugs to bug report or fix it, or better fix it and send pull request :) #### Contributors @@ -21,11 +24,28 @@ Via NPM: ```bash npm install ionic-cache --save -cordova plugin add cordova-sqlite-storage --save ``` And inject service to your app: +*app.module.ts* + +```ts +import {CacheService} from "ionic-cache/ionic-cache"; + +@NgModule({ + ... + bootstrap: [IonicApp], + entryComponents: [ + MyApp, + AboutPage + ], + providers: [CacheService], +}) +``` + +*app.component.ts* + ```ts import {CacheService} from "ionic-cache/ionic-cache"; @@ -40,9 +60,6 @@ class MyApp { } ... } -ionicBootstrap(MyApp, [ - CacheService -]); ``` ## Usage diff --git a/package.json b/package.json index 0105597..58dca17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ionic-cache", - "version": "1.0.9", + "version": "1.1.0", "description": "Ionic cache service - cache request, data, promises etc.", "main": "ionic-cache.js", "scripts": { @@ -23,14 +23,17 @@ }, "homepage": "https://github.com/Nodonisko/ionic-cache#readme", "dependencies": { - "@angular/core": "^2.0.0-rc.4", - "rxjs": "^5.0.0-beta.6" + "@angular/core": "^2.0.2", + "@angular/http": "^2.0.2", + "@angular/platform-browser": "^2.0.2", + "rxjs": "^5.0.0-beta.12", + "zone.js": "^0.6.21" }, "devDependencies": { - "tslint": "^3.13.0", - "tslint-ionic-rules": "^0.0.3", - "typescript": "^1.8.10", - "typings": "^1.3.1" + "tslint": "^3.15.1", + "tslint-ionic-rules": "^0.0.6", + "typescript": "^2.0.3", + "typings": "^1.4.0" }, "typings": "./ionic-cache.d.ts" } diff --git a/src/cache.service.ts b/src/cache.service.ts index dbdd26b..f89d195 100644 --- a/src/cache.service.ts +++ b/src/cache.service.ts @@ -23,7 +23,6 @@ export class CacheService { private networkStatus: boolean = true; constructor() { - console.log('constructor'); try { this.storage = new SqlStorage(); this.watchNetworkInit(); @@ -128,8 +127,6 @@ export class CacheService { let query = `INSERT OR REPLACE INTO ${this.tableName} (${Object.keys(valuesMap).join(', ')}) VALUES (${values.join(', ')})`; - console.log(query); - return this.storage.query(query).then(() => data); } diff --git a/src/storage.ts b/src/storage.ts index 45ca177..c894b1c 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -5,6 +5,10 @@ export class SqlStorage { this.database = window.openDatabase('cache', '1.0', 'cache', 5 * 1024 * 1024); } + /** + * @description Call database query + * @return {Promise} + */ public query(query: String): Promise { return new Promise((resolve, reject) => { this.database.transaction((tx) => {