Skip to content

Commit a2fc296

Browse files
committed
Add minor improvements for javascript code walkthrough
1 parent 01ed305 commit a2fc296

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

_code-samples/get-started/js/get-acct-info.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// @chunk {"steps": ["import-node-tag"]}
12
// Import the library
2-
// @chunk {"steps": ["connect-tag"]}
33
import xrpl from "xrpl"
4+
// @chunk-end
45

6+
// @chunk {"steps": ["connect-tag"]}
57
// Define the network client
68
const SERVER_URL = "wss://s.altnet.rippletest.net:51233/"
79
const client = new xrpl.Client(SERVER_URL)

docs/tutorials/javascript/build-apps/get-started.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ Click **Download** on the top right of the code preview panel to download the so
6262

6363
Follow the steps to create a simple application with `xrpl.js`.
6464

65-
### 1. Install Dependencies
66-
6765
<!-- Web steps -->
6866
{% step id="import-web-tag" when={ "environment": "Web" } %}
67+
### 1. Install Dependencies
68+
6969
To load `xrpl.js` into your project, add a `<script>` tag to your HTML.
7070

7171
You can load the library from a CDN as in the example, or download a release and host it on your own website.
@@ -74,7 +74,8 @@ This loads the module into the top level as `xrpl`.
7474
{% /step %}
7575

7676
<!-- Node.js steps -->
77-
{% step id="install-node-tag" when={ "environment": "Node" } %}
77+
{% step id="import-node-tag" when={ "environment": "Node" } %}
78+
### 1. Install Dependencies
7879

7980
Start a new project by creating an empty folder, then move into that folder and use [NPM](https://www.npmjs.com/) to install the latest version of xrpl.js:
8081

@@ -145,31 +146,32 @@ If you want to generate a wallet without funding it, you can create a new `Walle
145146
To use an existing wallet seed encoded in [base58][], you can create a `Wallet` instance from it.
146147
{% /step %}
147148

149+
{% step id="query-xrpl-tag" %}
148150
### 4. Query the XRP Ledger
149151

150-
{% step id="query-xrpl-tag" %}
151152
Use the Client's `request()` method to access the XRP Ledger's [WebSocket API](../../../references/http-websocket-apis/api-conventions/request-formatting.md).
152153
{% /step %}
153154

155+
{% step id="listen-for-events-tag" %}
154156
### 5. Listen for Events
155157

156-
{% step id="listen-for-events-tag" %}
157158
You can set up handlers for various types of events in `xrpl.js`, such as whenever the XRP Ledger's [consensus process](../../../concepts/consensus-protocol/index.md) produces a new [ledger version](../../../concepts/ledgers/index.md). To do that, first call the [subscribe method][] to get the type of events you want, then attach an event handler using the `on(eventType, callback)` method of the client.
158159
{% /step %}
159160
161+
{% step id="disconnect-node-tag" when={ "environment": "Node" } %}
160162
### 6. Disconnect
161163
162-
{% step id="disconnect-node-tag" when={ "environment": "Node" } %}
163164
Disconnect when done so Node.js can end the process. The example code waits 10 seconds before disconnecting to allow time for the ledger event listener to receive and display events.
164165
{% /step %}
165166
166167
{% step id="disconnect-web-tag" when={ "environment": "Web" } %}
168+
### 6. Disconnect
167169
Disconnect from the ledger when done. The example code waits 10 seconds before disconnecting to allow time for the ledger event listener to receive and display events.
168170
{% /step %}
169171
172+
{% step id="run-app-node-tag" when={ "environment": "Node" } %}
170173
### 7. Run the Application
171174
172-
{% step id="run-app-node-tag" when={ "environment": "Node" } %}
173175
Finally, in your terminal, run the application like so:
174176
175177
```sh

0 commit comments

Comments
 (0)