Skip to content

Commit

Permalink
Make the set_subscribe_callback boolean an input paramater with defau…
Browse files Browse the repository at this point in the history
…lt true
  • Loading branch information
svk31 committed Mar 22, 2018
1 parent 1a27ff7 commit 943539b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions examples/chainStore.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {Apis} from "bitsharesjs-ws";
import {ChainStore} from "../lib";

Apis.instance("wss://bitshares.openledger.info/ws", true).init_promise.then((res) => {
Apis.instance("wss://eu.nodes.bitshares.ws", true).init_promise.then(res => {
console.log("connected to:", res[0].network);
ChainStore.init().then(() => {
ChainStore.init(false).then(() => {
ChainStore.subscribe(updateState);
});
});

let dynamicGlobal = null;
function updateState(object) {
dynamicGlobal = ChainStore.getObject("2.1.0");
// dynamicGlobal = ChainStore.getObject("2.1.0");

console.log("ChainStore object update\n", dynamicGlobal ? dynamicGlobal.toJS() : dynamicGlobal);
console.log("ChainStore object update");
}
10 changes: 5 additions & 5 deletions lib/chain/src/ChainStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,21 @@ class ChainStore {
this.dispatched = false;
}

resetCache() {
resetCache(subscribe_to_new) {
this.subscribed = false;
this.subError = null;
this.clearCache();
this.head_block_time_string = null;
return this.init().catch(err => {
console.log("resetCache init error:", err);
return this.init(subscribe_to_new).catch(err => {
console.log("resetCache init error:", err());
});
}

setDispatchFrequency(freq) {
this.dispatchFrequency = freq;
}

init() {
init(subscribe_to_new = true) {
let reconnectCounter = 0;
var _init = (resolve, reject) => {
if (this.subscribed) return resolve();
Expand Down Expand Up @@ -163,7 +163,7 @@ class ChainStore {
.db_api()
.exec("set_subscribe_callback", [
this.onUpdate.bind(this),
true
subscribe_to_new
])
.then(() => {
console.log(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitsharesjs",
"version": "1.5.3",
"version": "1.5.4",
"description":
"Pure JavaScript Bitshares library for node.js and browsers.",
"browser": {
Expand Down

0 comments on commit 943539b

Please sign in to comment.