Skip to content

Commit d94990d

Browse files
committed
Grammar check
1 parent 90abddf commit d94990d

File tree

1 file changed

+37
-50
lines changed

1 file changed

+37
-50
lines changed

_posts/2022-03-02-rx-stomp-with-angular.md

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ toc: true
77
---
88

99
This step by step guide will create a new Angular application
10-
and demonstrate usage of rx-stomp.
10+
and demonstrate usage of [rx-stomp].
1111

12-
While preparing this guide `Angular` `13.2.0` and
12+
While preparing this guide, `Angular` `13.2.0` and
1313
`@stomp/rx-stomp` `1.1.4` are used.
1414

15-
For the impatient, final code from this tutorial is at:
15+
For the impatient, the final code from this tutorial is at:
1616
[https://github.com/stomp-js/rx-stomp-angular]
1717

18-
## Pre requisites
18+
## Prerequisites
1919

2020
You need to have [Node.js](https://nodejs.org)
2121
and [npm](https://www.npmjs.com/) installed.
@@ -33,21 +33,20 @@ Install latest Angular CLI as below:
3333
$ npm i @angular/cli -g
3434
```
3535

36-
Change to the folder where you want to create the application
37-
and create your new application:
36+
Change to the intended folder and create your new application:
3837

3938
```bash
4039
$ ng new rx-stomp-angular --skip-install --defaults
4140
```
4241

43-
Change to new created folder and install all dependencies:
42+
Change to newly created folder and install all dependencies:
4443

4544
```bash
4645
$ cd rx-stomp-angular/
4746
$ npm i
4847
```
4948

50-
To run the application locally execute the following and
49+
To run the application locally, execute the following and
5150
point your browser to [http://localhost:4200/](http://localhost:4200/).
5251

5352
```bash
@@ -57,7 +56,7 @@ $ ng serve
5756
You can keep it running in a terminal and keep the browser tab open.
5857
It will detect changes, recompile and reload the browser tab.
5958

60-
_At this stage you can use favorite IDE and be ready to edit code._
59+
_At this stage, you can use your favorite IDE and be ready to edit code._
6160

6261
### Add @stomp/rx-stomp, Inject RxStompService
6362

@@ -66,8 +65,8 @@ $ npm i @stomp/rx-stomp
6665
```
6766

6867
We will need to define our configuration.
69-
This configuration will get injected by Angular Dependency Injection mechanism
70-
while creating instance of `RxStompService`.
68+
This configuration will get injected by the Angular Dependency Injection mechanism
69+
while creating an instance of `RxStompService`.
7170

7271
#### Configuration
7372

@@ -106,7 +105,7 @@ export const myRxStompConfig: RxStompConfig = {
106105
};
107106
```
108107

109-
The above should work for a out of the box installation of RabbitMQ broker.
108+
The above should work for an out-of-the-box installation of RabbitMQ broker.
110109
Please change as per your broker configuration.
111110

112111
#### The RxStompService
@@ -141,7 +140,7 @@ export function rxStompServiceFactory() {
141140

142141
#### Angular DI setup
143142

144-
Next we need the service get injected. Open `src/app/app.module.ts`
143+
Next, we need the service to get injected. Open `src/app/app.module.ts`
145144
Add the following to the `providers` array of your `@NgModule`:
146145

147146
```typescript
@@ -153,7 +152,7 @@ providers: [
153152
]
154153
```
155154

156-
Also add appropriate import lines towards the top of this file (after existing import
155+
Also, add appropriate import lines towards the top of this file (after the existing import
157156
statements):
158157

159158
```typescript
@@ -165,7 +164,7 @@ import { rxStompServiceFactory } from './rx-stomp-service-factory';
165164

166165
We will create a component that will do the following:
167166

168-
- It will have a click-able button to send a message.
167+
- It will have a clickable button to send a message.
169168
- It will subscribe and keep listing all received messages.
170169

171170
#### Skeleton
@@ -193,7 +192,7 @@ Now we will create the basic HTML in
193192
```
194193

195194
We will add this component to the main UI by editing `src/app/app.component.html`.
196-
In this process we will remove most of the default HTML generated by Angular CLI.
195+
We will remove most of the default HTML generated by Angular CLI in this process.
197196
Edit `src/app/app.component.html` to look like the following:
198197

199198
```html
@@ -203,24 +202,23 @@ Edit `src/app/app.component.html` to look like the following:
203202
<app-messages></app-messages>
204203
```
205204

206-
This is a great time to check the browser tab to see that display has changed
205+
Now is a great time to check the browser tab to see that display has changed
207206
and it should show the HTML that we have added to `src/app/messages/messages.component.html`.
208207

209-
If you find an empty screen, please check the terminal where you executed `ng serve`, if
210-
there are compilation errors you would see it here. Also, see the browser Javascript
211-
console, sometimes you may notice errors here.
208+
If you find an empty screen, please check the terminal where you executed `ng serve`.
209+
If there are compilation errors, you will see them here. Also, check the browser Javascript console. Sometimes, you may notice errors here.
212210

213211
#### Sending messages
214212

215213
We will now inject `RxStompService` as a dependency in `MessageComponent`.
216-
To that we will add it to the constructor in `src/app/messages/messages.component.ts`,
214+
To achieve that, we will add it to the constructor in `src/app/messages/messages.component.ts`,
217215
which should look like the following:
218216

219217
```typescript
220218
constructor(private rxStompService: RxStompService) { }
221219
```
222220

223-
We will now add code to send message:
221+
We will now add code to send a message:
224222

225223
```typescript
226224
onSendMessage() {
@@ -230,9 +228,9 @@ We will now add code to send message:
230228
```
231229

232230
_Please see [RxStomp#publish][rx-stomp-publish].
233-
Keep this page open as we would be using more methods from this class soon._
231+
Keep this page open as we will be using more methods from this class soon._
234232

235-
Full content of `src/app/messages/messages.component.ts` should look like
233+
The entire content of `src/app/messages/messages.component.ts` should look like
236234
the following:
237235

238236
```typescript
@@ -256,7 +254,7 @@ export class MessagesComponent implements OnInit {
256254
}
257255
```
258256

259-
We will attach `onSendMessage` to the button in the html.
257+
We will attach `onSendMessage` to the button in the HTML.
260258
Edit `src/app/messages/messages.component.html` and add `(click)="onSendMessage()"`
261259
to the button. The file should look like the following now:
262260

@@ -273,9 +271,9 @@ to the button. The file should look like the following now:
273271
</div>
274272
```
275273

276-
At this stage you should go back to the browser tab and open the web console.
277-
When you click on the `Send Message` button, you can see in the console that message
278-
is being sent to the broker.
274+
You should go back to the browser tab and open the web console at this stage.
275+
When you click on the `Send Message` button, you can see that the message
276+
is being sent to the broker in the console.
279277

280278
#### Receiving messages
281279

@@ -293,19 +291,17 @@ Typically we will subscribe this `Observable` to receive actual messages.
293291
}
294292
```
295293

296-
We will need to add a declaration for `receivedMessages` and import `Message`
297-
from `@stomp/stompjs`.
298-
There are `Message` classes exposed by few other modules as well, so,
299-
you need to be careful.
294+
We will need to add a declaration for `receivedMessages` and import `Message` from `@stomp/stompjs`.
295+
A few other modules also expose `Message` classes, so you need to be careful.
300296

301297
_If you are coming from `@stomp/stompjs`, please notice that you do not
302-
need to subscribe within callback of stomp getting connected.
303-
This library internally ensures that actual subscription is carried out
298+
need to subscribe within the callback of stomp getting connected.
299+
This library internally ensures that actual subscription happens
304300
when the broker is actually connected.
305-
It also keep tracking of broker re-connections and automatically resubscribes._
301+
It also keeps tracking of broker re-connections and automatically resubscribes._
306302

307303
Now is the time to link the HTML template to received messages.
308-
We will use `ngFor` to bind list of messages to `<li>`.
304+
We will use `ngFor` to bind the list of messages to `<li>`.
309305
Edit `src/app/messages/messages.component.html`:
310306

311307
```html
@@ -358,22 +354,18 @@ export class MessagesComponent implements OnInit {
358354
</div>
359355
```
360356

361-
Check your application in the browser now. Try sending few messages.
362-
Open another browser window/tab and see messages being received in both.
357+
Check your application in the browser now - try sending a few messages. Then open another browser window/tab and see that both receive messages.
363358

364359
### Stopping the watch
365360

366-
We are almost done, we just need to add stopping the watch when the component is destroyed.
367-
For this we need to call `unsubscribe` on the RxJS subscription when we are done.
368-
`MessagesComponent` will need to implement `OnDestroy`. For this we will need to do
369-
the following:
361+
We are almost done. We need to add stopping the watch when the component is destroyed. For this, we need to call `unsubscribe` on the RxJS subscription. We will need to do the following:
370362

371-
- Add `OnDestroy` to the implements list (by default `OnInit` will be there).
363+
- Add `OnDestroy` to the implements list (by default, `OnInit` will be there).
372364
- Implement `ngOnDestroy` method.
373365
- Add `OnDestroy` to the imports.
374366

375-
Once the above is done we will modify code in `ngOnInit` to store the RxJS
376-
subscription in a member variable and call `unsusbscribe` in `ngOnDestroy`.
367+
After this, we will modify the code in `ngOnInit` to store the RxJS
368+
subscription in a member variable and call `unsubscribe` in `ngOnDestroy`.
377369

378370
```typescript
379371
ngOnInit() {
@@ -439,11 +431,6 @@ export class MessagesComponent implements OnInit, OnDestroy {
439431
- Using [token authentication](/faqs/faqs.html#p-can-i-use-token-based-authentication-with-these-libraries-p)
440432
with the STOMP broker.
441433

442-
I will be writing more tutorials in following days to cover additional topics:
443-
444-
- Manual control in the configuration and connection establishment.
445-
(In this sample, STOMP broker is connected during the Angular DI class
446-
initialization phase.)
447434

448435
[tour-of-heroes]: https://angular.io/tutorial
449436
[angular-di]: https://angular.io/guide/dependency-injection

0 commit comments

Comments
 (0)