Skip to content

Commit

Permalink
updated react example
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwalguptaofficial committed Jun 3, 2019
1 parent 280d63d commit feae3d9
Show file tree
Hide file tree
Showing 8 changed files with 3,767 additions and 6,076 deletions.
12 changes: 11 additions & 1 deletion examples/react/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"presets": ["env", "react"]
"presets": [
["@babel/preset-env", {
"targets": {
"browsers": [
">0.25%",
"not ie 11",
"not op_mini all"
]
}
}], "@babel/preset-react",
]
}
9,469 changes: 3,686 additions & 5,783 deletions examples/react/package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
"author": "",
"license": "ISC",
"dependencies": {
"jsstore": "^2.8.0",
"jsstore": "^3.0.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"sqlweb": "^1.2.0"
"sqlweb": "^1.3.0"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.6",
"file-loader": "^3.0.1",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15",
"webpack-dev-server": "^3.1.10",
"worker-loader": "^1.1.1"
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.5.1"
}
}
2 changes: 1 addition & 1 deletion examples/react/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<meta charset="UTF-8">
<title>JsStore Webpack Example</title>
<title>JsStore React Example</title>
</head>

<body>
Expand Down
16 changes: 5 additions & 11 deletions examples/react/src/service/base_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export class BaseService {

constructor() {
this.dbName = "students_db";
this.connection.setLogStatus(true);
this.initJsStore();
}

Expand All @@ -14,16 +13,11 @@ export class BaseService {
}

initJsStore() {
this.connection.runSql(`ISDBEXIST ${this.dbName}`).then((isExist) => {
if (isExist) {
const qry = 'OPENDB ' + this.dbName;
this.connection.runSql(qry);
} else {
const qry = this.getDbQuery();
this.connection.runSql(qry);
}
}).catch(err => {
console.error(err);
const qry = this.getDbQuery();
this.connection.runSql(qry).then(function () {
console.log('db initiated');
}).catch(function (ex) {
console.error(ex);
})
}

Expand Down
18 changes: 14 additions & 4 deletions examples/react/src/service/idb_service.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import * as JsStore from "jsstore";
import * as SqlWeb from 'sqlweb';
import * as JsStore from 'jsstore';
import * as SqlWeb from "sqlweb";
const getWorkerPath = () => {
if (process.env.NODE_ENV === 'development') {
return require("file-loader?name=scripts/[name].[hash].js!jsstore/dist/jsstore.worker.js");
}
else {
return require("file-loader?name=scripts/[name].[hash].js!jsstore/dist/jsstore.worker.min.js");
}
};

JsStore.useSqlWeb(SqlWeb);
const Worker = require("worker-loader?publicPath=/&name=jsstore.worker.js!jsstore/dist/jsstore.worker.min");

// This will ensure that we are using only one instance.
// Otherwise due to multiple instance multiple worker will be created.
export const idbCon = new JsStore.Instance(new Worker());
const workerPath = getWorkerPath();
const worker = new Worker(workerPath);
export const idbCon = new JsStore.Instance(worker);
Loading

0 comments on commit feae3d9

Please sign in to comment.