Skip to content

Commit 778c4ed

Browse files
committed
Explicit constructor for RxStompService - Angular 15 compatibility.
1 parent 0b98fad commit 778c4ed

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ import { RxStomp } from '@stomp/rx-stomp';
121121
@Injectable({
122122
providedIn: 'root',
123123
})
124-
export class RxStompService extends RxStomp {}
124+
export class RxStompService extends RxStomp {
125+
constructor() {
126+
super();
127+
}
128+
}
125129
```
126130

127131
#### Factory to create and initialize RxStompService
@@ -151,7 +155,7 @@ providers: [
151155
provide: RxStompService,
152156
useFactory: rxStompServiceFactory,
153157
},
154-
]
158+
];
155159
```
156160

157161
Also, add appropriate import lines towards the top of this file (after the existing import
@@ -406,10 +410,10 @@ export class MessagesComponent implements OnInit, OnDestroy {
406410

407411
ngOnInit() {
408412
this.topicSubscription = this.rxStompService
409-
.watch('/topic/demo')
410-
.subscribe((message: Message) => {
411-
this.receivedMessages.push(message.body);
412-
});
413+
.watch('/topic/demo')
414+
.subscribe((message: Message) => {
415+
this.receivedMessages.push(message.body);
416+
});
413417
}
414418

415419
ngOnDestroy() {
@@ -432,11 +436,11 @@ export class MessagesComponent implements OnInit, OnDestroy {
432436
- Using [token authentication](/faqs/faqs.html#p-can-i-use-token-based-authentication-with-these-libraries-p)
433437
with the STOMP broker.
434438

435-
436439
[tour-of-heroes]: https://angular.io/tutorial
437440
[angular-di]: https://angular.io/guide/dependency-injection
438441
[rx-stomp]: /api-docs/latest/classes/RxStomp.html
439442
[rx-stomp-publish]: /api-docs/latest/classes/RxStomp.html#publish
440443
[rx-stomp-watch]: /api-docs/latest/classes/RxStomp.html#watch
441444
[https://github.com/stomp-js/rx-stomp-angular]: https://github.com/stomp-js/rx-stomp-angular
445+
442446
[connection-status-ng2-stompjs]: {% link _posts/2018-12-18-connection-status-ng2-stompjs.md %}

_posts/2022-03-03-ng2-stompjs-to-rx-stomp.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ import { RxStomp } from '@stomp/rx-stomp';
3838
@Injectable({
3939
providedIn: 'root',
4040
})
41-
export class RxStompService extends RxStomp {}
41+
export class RxStompService extends RxStomp {
42+
constructor() {
43+
super();
44+
}
45+
}
4246
```
4347

4448
Create `rx-stomp-service-factory.ts` file inside `src/app/` with the following content:
@@ -69,7 +73,7 @@ providers: [
6973
provide: RxStompService,
7074
useFactory: rxStompServiceFactory,
7175
},
72-
]
76+
];
7377
```
7478

7579
Remove the old imports and add the imports from the newly created modules.
@@ -85,4 +89,5 @@ Change the import path for `RxStompService` from `@stomp/ng2-stompjs` to the loc
8589

8690
[rx-stomp]: /api-docs/latest/classes/RxStomp.html
8791
[RxStompConfig]: /api-docs/latest/classes/RxStompConfig.html
92+
8893
[Using rx-stomp with Angular]: {% link _posts/2022-03-02-rx-stomp-with-angular.md %}

0 commit comments

Comments
 (0)