You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -230,9 +228,9 @@ We will now add code to send message:
230
228
```
231
229
232
230
_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._
234
232
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
236
234
the following:
237
235
238
236
```typescript
@@ -256,7 +254,7 @@ export class MessagesComponent implements OnInit {
256
254
}
257
255
```
258
256
259
-
We will attach `onSendMessage` to the button in the html.
257
+
We will attach `onSendMessage` to the button in the HTML.
260
258
Edit `src/app/messages/messages.component.html` and add `(click)="onSendMessage()"`
261
259
to the button. The file should look like the following now:
262
260
@@ -273,9 +271,9 @@ to the button. The file should look like the following now:
273
271
</div>
274
272
```
275
273
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.
279
277
280
278
#### Receiving messages
281
279
@@ -293,19 +291,17 @@ Typically we will subscribe this `Observable` to receive actual messages.
293
291
}
294
292
```
295
293
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.
300
296
301
297
_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
304
300
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._
306
302
307
303
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>`.
309
305
Edit `src/app/messages/messages.component.html`:
310
306
311
307
```html
@@ -358,22 +354,18 @@ export class MessagesComponent implements OnInit {
358
354
</div>
359
355
```
360
356
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.
363
358
364
359
### Stopping the watch
365
360
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:
370
362
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).
372
364
- Implement `ngOnDestroy` method.
373
365
- Add `OnDestroy` to the imports.
374
366
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`.
0 commit comments