diff --git a/.cspell.json b/.cspell.json index 82d6d34fc7..0018ca4d89 100644 --- a/.cspell.json +++ b/.cspell.json @@ -40,6 +40,7 @@ "ipfs", "iwant", "jdev", + "jswaku", "keccak", "lastpub", "libauth", diff --git a/README.md b/README.md index 70506864b8..00c42e9fa8 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,42 @@ Install `js-waku` package: npm install js-waku ``` +### Import js-waku + +To use js-waku in your application, you can: + +use `import`: + +```js +import { Waku } from 'js-waku'; + +const waku = await Waku.create(); +``` + +use `require`: + +```js +const jsWaku = require('js-waku'); + +jsWaku.Waku.create().then(waku => { + // ... +}); +``` + +Or directly import it in a ` + +``` + ### Start a waku node ```ts -import { Waku } from 'js-waku'; - const waku = await Waku.create({ bootstrap: true }); ``` diff --git a/examples/examples.md b/examples/examples.md index bb7a4f8b49..e1dac59613 100644 --- a/examples/examples.md +++ b/examples/examples.md @@ -6,3 +6,4 @@ Here is the list of the code examples and the features they demonstrate: - [Ethereum Private Message Web App](eth-pm): Private Messaging, React/TypeScript, Light Push, Signature with Web3, Asymmetric Encryption. - [Minimal ReactJS Chat App](min-react-js-chat): Group chat, React/JavaScript, Relay, Protobuf using `protons`. - [Minimal ReactJS Waku Store App](store-reactjs-chat): Waku Store, React/JavaScript, Protobuf using `protons`. +- [Pure Javascript Using Minified Library](unpkg-js-store): Stop retrieving results from Waku Store on condition, Use minified bundle from Unpkg.com, JavaScript. diff --git a/examples/unpkg-js-store/README.md b/examples/unpkg-js-store/README.md new file mode 100644 index 0000000000..73e1525375 --- /dev/null +++ b/examples/unpkg-js-store/README.md @@ -0,0 +1,11 @@ +# Pure Javascript Using Minified Library + +**Demonstrates**: + +- Waku Store: Using a condition to stop retrieving results from Waku Store. +- Pure Javascript/HTML. +- Use minified bundle of js from unpkg.com, no import, no package manager. + +This example uses Waku Store to retrieve the latest ping relay message (used for keep alive purposes) and displays its timestamp. + +To test the example, simply download the `index.html` file from this folder and open it in a browser. diff --git a/examples/unpkg-js-store/index.html b/examples/unpkg-js-store/index.html new file mode 100644 index 0000000000..cddaa07b03 --- /dev/null +++ b/examples/unpkg-js-store/index.html @@ -0,0 +1,84 @@ + + + +
+ + +