@@ -15,19 +15,37 @@ const ORBIT_DB_DOCS =
15
15
const ORBIT_DB_KEYVALUE =
16
16
"/orbitdb/zdpuAod4qh5m3SmjuSVtLUEspqp1yCQABWm1iEdSPFDQ5mUkU/react-ortbitdb-keyvalue" ;
17
17
18
+ const ORBIT_DB_COUNTER =
19
+ "/orbitdb/zdpuAzbF3ZzhMsbtw4vkKoP1BEcH1CbgE1fRMUuykQdcbHe7X/react-ortbitdb-counter" ;
20
+
18
21
const Intro = ( ) => (
19
22
< div className = "jumbotron" >
20
23
< h1 className = "display-4" > react-orbitdb</ h1 >
21
24
< p className = "lead" >
22
25
React hooks and providers for dealing with IPFS Orbit-db datasources.
23
26
</ p >
24
27
< hr className = "my-4" />
28
+ < p >
29
+ On this page you can find different examples of OrbitDB databases. < br />
30
+ Other visitors can also interact in real-time with the data. < br />
31
+ < br />
32
+ < b > No server!</ b >
33
+ </ p >
34
+ < hr className = "my-4" />
25
35
< a
26
36
className = "btn btn-outline-primary"
27
37
href = "https://github.com/revolunet/react-orbitdb"
28
38
role = "button"
29
39
>
30
- See on GitHub
40
+ See project on GitHub
41
+ </ a >
42
+
43
+ < a
44
+ className = "btn btn-outline-primary"
45
+ href = "https://github.com/revolunet/react-orbitdb/blob/master/example/src/index.js"
46
+ role = "button"
47
+ >
48
+ This page source code
31
49
</ a >
32
50
</ div >
33
51
) ;
@@ -153,7 +171,6 @@ const KeyValueDemo = () => {
153
171
create : true ,
154
172
public : true ,
155
173
} ) ;
156
- console . log ( "records" , records ) ;
157
174
const addKey = async ( ) => {
158
175
const [ key , value ] = newKeyValue ( ) ;
159
176
await db . put ( key , value ) ;
@@ -217,7 +234,7 @@ const EventLogDemo = () => {
217
234
} ;
218
235
useEffect ( ( ) => {
219
236
if ( db ) {
220
- console . log ( " add an event on first load" ) ;
237
+ // add an event on first load
221
238
addEvent ( ) ;
222
239
}
223
240
} , [ db ] ) ;
@@ -236,7 +253,7 @@ const EventLogDemo = () => {
236
253
</ span > { " " }
237
254
< button
238
255
style = { { marginLeft : 10 } }
239
- className = "btn btn-outline-primary"
256
+ className = "btn btn-outline-primary"
240
257
onClick = { addEvent }
241
258
>
242
259
Add
@@ -269,16 +286,60 @@ const EventLogDemo = () => {
269
286
) ;
270
287
} ;
271
288
289
+ const CounterDemo = ( ) => {
290
+ const { inc, value } = useOrbitDb ( ORBIT_DB_COUNTER , {
291
+ type : "counter" ,
292
+ create : true ,
293
+ public : true ,
294
+ } ) ;
295
+ const add = ( ) => {
296
+ inc ( ) ;
297
+ } ;
298
+ return (
299
+ < div >
300
+ < p style = { { fontSize : "0.8em" } } >
301
+ { ( value && `Connected to ${ ORBIT_DB_COUNTER } ` ) ||
302
+ `Connecting to ${ ORBIT_DB_COUNTER } ...` }
303
+ </ p >
304
+ { value && (
305
+ < h1 >
306
+ < span
307
+ className = "badge badge-primary"
308
+ style = { { fontVariantNumeric : "tabular-nums" } }
309
+ >
310
+ { value }
311
+ </ span >
312
+ < button
313
+ style = { { marginLeft : 10 } }
314
+ className = "btn btn-outline-primary"
315
+ onClick = { add }
316
+ >
317
+ Add
318
+ </ button >
319
+ </ h1 >
320
+ ) }
321
+ </ div >
322
+ ) ;
323
+ } ;
324
+
272
325
const App = ( ) => (
273
326
< div >
274
327
< OrbitProvider >
275
328
< Intro />
329
+ < h2 > counter</ h2 >
330
+ < CounterDemo />
331
+ < br />
276
332
< h2 > eventlog</ h2 >
277
333
< EventLogDemo />
334
+ < br />
278
335
< h2 > docstore</ h2 >
279
336
< DocStoreDemo />
337
+ < br />
280
338
< h2 > keyvalue</ h2 >
281
339
< KeyValueDemo />
340
+ < p > </ p >
341
+ < p > </ p >
342
+ < p > </ p >
282
343
</ OrbitProvider >
283
344
</ div >
284
345
) ;
0 commit comments