diff --git a/example/src/index.js b/example/src/index.js
index 908d11c..503beed 100644
--- a/example/src/index.js
+++ b/example/src/index.js
@@ -6,17 +6,17 @@ import { OrbitProvider, useOrbitDb } from "../../src";
window.LOG = "*";
-const ORBIT_DB_EVENTS =
- "/orbitdb/zdpuB2cZqW3mNmAM1tZ6mNPpcw6bSdNKNgPw4ppqJpnjS8Teg/react-ortbitdb-eventlog";
+const ORBIT_DB_EVENTS = "react-ortbitdb-eventlog";
+//"/orbitdb/zdpuB2cZqW3mNmAM1tZ6mNPpcw6bSdNKNgPw4ppqJpnjS8Teg/react-ortbitdb-eventlog";
-const ORBIT_DB_DOCS =
- "/orbitdb/zdpuAknUxcYsKArW2d8KtBhwyLfkmADo4wpwmC8ReKy3Q5pDR/react-ortbitdb-docstore";
+const ORBIT_DB_DOCS = "react-ortbitdb-docstore";
+//"/orbitdb/zdpuAknUxcYsKArW2d8KtBhwyLfkmADo4wpwmC8ReKy3Q5pDR/react-ortbitdb-docstore";
-const ORBIT_DB_KEYVALUE =
- "/orbitdb/zdpuAod4qh5m3SmjuSVtLUEspqp1yCQABWm1iEdSPFDQ5mUkU/react-ortbitdb-keyvalue";
+const ORBIT_DB_KEYVALUE = "react-ortbitdb-keyvalue";
+//"/orbitdb/zdpuAod4qh5m3SmjuSVtLUEspqp1yCQABWm1iEdSPFDQ5mUkU/react-ortbitdb-keyvalue";
-const ORBIT_DB_COUNTER =
- "/orbitdb/zdpuAzbF3ZzhMsbtw4vkKoP1BEcH1CbgE1fRMUuykQdcbHe7X/react-ortbitdb-counter";
+const ORBIT_DB_COUNTER = "react-ortbitdb-counter";
+//"/orbitdb/zdpuAzbF3ZzhMsbtw4vkKoP1BEcH1CbgE1fRMUuykQdcbHe7X/react-ortbitdb-counter";
const Intro = () => (
@@ -312,10 +312,10 @@ const CounterDemo = () => {
return (
- {(value && `Connected to ${ORBIT_DB_COUNTER}`) ||
+ {(value !== undefined && `Connected to ${ORBIT_DB_COUNTER}`) ||
`Connecting to ${ORBIT_DB_COUNTER}...`}
- {value && (
+ {value !== undefined && (
{
if (!address) return;
const createDb = async () => {
+ logger.debug("orbit.create", address);
+
const allOptions = {
indexBy: "id",
- create: false,
+ create: true, // doesnt really work ?
type: "keyvalue",
overwrite: false,
...options,
- // options.public controls write access
+ // // options.public controls write access
...(options.create && options.public
? publicWrite(orbit)
: publicRead(orbit)),
};
- logger.debug("orbit.open", address, allOptions);
- const db = await orbit.open(address, allOptions);
+ const dbAddress = await orbit.determineAddress(
+ address,
+ allOptions.type,
+ allOptions
+ );
+ logger.debug("orbit.open", dbAddress, allOptions);
+ const db = await orbit.open(dbAddress, allOptions);
logger.debug("orbitdb.opened", db.address.toString());
const refreshDb = async () => {
await db.load();
@@ -75,6 +82,11 @@ const useOrbitDb = (address, options = {}) => {
logger.debug("db.events.write", address.toString());
refreshDb();
});
+
+ db.events.on("error", (err) => {
+ logger.debug("db.events.error", err);
+ refreshDb();
+ });
await refreshDb();
};
if (orbit) {
diff --git a/yarn.lock b/yarn.lock
index 8b461c1..1c79209 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2800,9 +2800,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001043:
- version "1.0.30001078"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001078.tgz#e1b6e2ae327b6a1ec11f65ec7a0dde1e7093074c"
- integrity sha512-sF12qXe9VMm32IEf/+NDvmTpwJaaU7N1igpiH2FdI4DyABJSsOqG3ZAcFvszLkoLoo1y6VJLMYivukUAxaMASw==
+ version "1.0.30001344"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001344.tgz"
+ integrity sha512-0ZFjnlCaXNOAYcV7i+TtdKBp0L/3XEU2MF/x6Du1lrh+SRX4IfzIVL4HNJg5pB2PmFb8rszIGyOvsZnqqRoc2g==
capture-exit@^2.0.0:
version "2.0.0"