Skip to content

Commit 4ff3cae

Browse files
committed
Address comments
1 parent 7d96ed2 commit 4ff3cae

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
**Key features:** Topics, Services, Actions, Parameters, Lifecycle Nodes, TypeScript support, RxJS Observables, Electron integration, ROS 2 in the browser (typed Web SDK + thin WebSocket gateway — `rclnodejs/web`, `rosocket`), and prebuilt binaries for Linux x64/arm64.
1717

1818
```javascript
19-
const rclnodejs = require('rclnodejs');
20-
rclnodejs.init().then(() => {
21-
const node = new rclnodejs.Node('publisher_example_node');
22-
const publisher = node.createPublisher('std_msgs/msg/String', 'topic');
23-
publisher.publish(`Hello ROS 2 from rclnodejs`);
24-
node.spin();
25-
});
19+
import rclnodejs from 'rclnodejs';
20+
21+
await rclnodejs.init();
22+
const node = new rclnodejs.Node('publisher_example_node');
23+
const publisher = node.createPublisher('std_msgs/msg/String', 'topic');
24+
publisher.publish(`Hello ROS 2 from rclnodejs`);
25+
node.spin();
2626
```
2727

2828
This example assumes your ROS 2 environment is already sourced.
@@ -105,7 +105,7 @@ npm install
105105
2. Run a publisher example from this checkout.
106106

107107
```bash
108-
node example/topics/publisher/publisher-example.cjs
108+
node example/topics/publisher/publisher-example.mjs
109109
```
110110

111111
More runnable examples in [example/](https://github.com/RobotWebTools/rclnodejs/tree/develop/example) and step-by-step guides in [tutorials/](./tutorials/).
@@ -146,7 +146,7 @@ how much glue you want to write.
146146
rclnodejs supports [RxJS](https://rxjs.dev/) Observable subscriptions for reactive programming with ROS 2 messages. Use operators like `throttleTime()`, `debounceTime()`, `map()`, and `combineLatest()` to build declarative message processing pipelines.
147147

148148
```javascript
149-
const { throttleTime, map } = require('rxjs');
149+
import { throttleTime, map } from 'rxjs';
150150

151151
const obsSub = node.createObservableSubscription(
152152
'sensor_msgs/msg/LaserScan',
@@ -173,7 +173,7 @@ rclnodejs auto-generates JavaScript bindings and TypeScript declarations for eve
173173
Use the generated types directly:
174174

175175
```javascript
176-
const rclnodejs = require('rclnodejs');
176+
import rclnodejs from 'rclnodejs';
177177
let stringMsgObject = rclnodejs.createMessageObject('std_msgs/msg/String');
178178
stringMsgObject.data = 'hello world';
179179
```

0 commit comments

Comments
 (0)