update example
This commit is contained in:
parent
c616fade27
commit
cbe4443033
|
@ -1,7 +1,7 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { StyleSheet, View, Text } from 'react-native';
|
import { StyleSheet, View, Text } from 'react-native';
|
||||||
import { defaultPubsubTopic, newNode, start, stop, peerID, relayEnoughPeers, listenAddresses, connect, peerCnt, peers, relayPublish, relayUnsubscribe, relaySubscribe, WakuMessage, onMessage } from '@waku/react-native';
|
import { defaultPubsubTopic, newNode, start, isStarted, stop, peerID, relayEnoughPeers, listenAddresses, connect, peerCnt, peers, relayPublish, relayUnsubscribe, relaySubscribe, WakuMessage, onMessage, storeQuery, StoreQuery } from '@waku/react-native';
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [result, setResult] = React.useState<string | undefined>();
|
const [result, setResult] = React.useState<string | undefined>();
|
||||||
|
@ -10,9 +10,12 @@ export default function App() {
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
await newNode(null); // TODO: This must be called only once
|
const nodeStarted = await isStarted();
|
||||||
await start(); // // TODO: This must be called only once
|
|
||||||
|
|
||||||
|
if (!nodeStarted) {
|
||||||
|
await newNode(null);
|
||||||
|
await start();
|
||||||
|
}
|
||||||
console.log("The node ID:", await peerID())
|
console.log("The node ID:", await peerID())
|
||||||
|
|
||||||
await relaySubscribe()
|
await relaySubscribe()
|
||||||
|
@ -42,6 +45,14 @@ export default function App() {
|
||||||
|
|
||||||
console.log("The messageID", messageID)
|
console.log("The messageID", messageID)
|
||||||
|
|
||||||
|
/*
|
||||||
|
console.log("Retrieving messages from store node")
|
||||||
|
const query = new StoreQuery();
|
||||||
|
//query.contentFilters.push("/toy-chat/2/luzhou/proto")
|
||||||
|
const queryResult = await storeQuery(query, "16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm")
|
||||||
|
console.log(queryResult)
|
||||||
|
*/
|
||||||
|
|
||||||
// await delay(5000) // Waiting 5s before unsubscribing
|
// await delay(5000) // Waiting 5s before unsubscribing
|
||||||
|
|
||||||
// console.log("Unsubscribing and stopping node...")
|
// console.log("Unsubscribing and stopping node...")
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.1.0
|
0.2.0
|
|
@ -63,7 +63,7 @@ class ReactNative: RCTEventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc(isStarted:withRejecter:)
|
@objc(isStarted:withRejecter:)
|
||||||
func stop(_ resolve:RCTPromiseResolveBlock, withRejecter reject:RCTPromiseRejectBlock) -> Void {
|
func isStarted(_ resolve:RCTPromiseResolveBlock, withRejecter reject:RCTPromiseRejectBlock) -> Void {
|
||||||
resolve(GowakuIsStarted())
|
resolve(GowakuIsStarted())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@waku/react-native",
|
"name": "@waku/react-native",
|
||||||
"version": "0.0.2",
|
"version": "0.0.4",
|
||||||
"description": "Waku React Native",
|
"description": "Waku React Native",
|
||||||
"author": "Status Research & Development GMBH",
|
"author": "Status Research & Development GMBH",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|
Loading…
Reference in New Issue