Skip to content

Commit 33d18ec

Browse files
style: use Finnish notation for subjects too
eslint-plugin-rxjs-x#91 discovered that suffix-subjects will allow the Finnish suffix too.
1 parent d845ce2 commit 33d18ec

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

src/bhs-web-angular-app/eslint.config.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,6 @@ export default tseslint.config(gitignore(), {
186186
// Add paramMap|data to defaults for ActivatedRoute.
187187
'^(canActivate|canActivateChild|canDeactivate|canLoad|intercept|resolve|validate|paramMap|data)$': false,
188188
},
189-
types: {
190-
// Add the subjects to defaults to work with suffix-subjects.
191-
'^(EventEmitter|BehaviorSubject|ReplaySubject|AsyncSubject|Subject)$': false,
192-
},
193189
},
194190
],
195191
'rxjs-x/suffix-subjects': 'warn',

src/bhs-web-angular-app/src/app/features/blog/components/posts-search/posts-search.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import { BlogService, PostPreview } from '@data/blog';
2424
export class PostsSearchComponent {
2525
private readonly blogService = inject(BlogService);
2626

27-
private readonly searchTextSubject = new BehaviorSubject('');
28-
postsVm$ = this.searchTextSubject.pipe(
27+
private readonly searchTextSubject$ = new BehaviorSubject('');
28+
postsVm$ = this.searchTextSubject$.pipe(
2929
switchMap(searchText => this.blogService.searchPosts(searchText).pipe(
3030
map(posts => ({ posts, error: null })),
3131
// Must do the catchError in this inner observable so it doesn't replace the outer observable and break search.
@@ -48,6 +48,6 @@ export class PostsSearchComponent {
4848

4949
onSearch(searchText: string): void {
5050
this.isLoading.set(true);
51-
this.searchTextSubject.next(searchText);
51+
this.searchTextSubject$.next(searchText);
5252
}
5353
}

src/bhs-web-angular-app/src/app/features/blog/pages/entry-edit/entry-edit.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class EntryEditComponent {
3434
private readonly blogService = inject(BlogService);
3535
private readonly auth = inject(AuthService);
3636

37-
private readonly submittedRequestSubject = new Subject<{ slug: string; body: PostRequest }>();
37+
private readonly submittedRequestSubject$ = new Subject<{ slug: string; body: PostRequest }>();
3838

3939
// Emit a merged combination of the initial post loaded from the URL, and the updated post after a submission.
4040
vm$ = merge(this.getInitialPost$(), this.getUpdatedPost$()).pipe(
@@ -81,7 +81,7 @@ export class EntryEditComponent {
8181
return { post, categories: allCategories, isLoading: false, currentAuthor };
8282
}),
8383
// Handle when the user submits an update.
84-
switchMap(vm => this.submittedRequestSubject.pipe(
84+
switchMap(vm => this.submittedRequestSubject$.pipe(
8585
// If any request is submitted, display loading.
8686
map(() => true),
8787
// Before any request is submitted, don't show loading.
@@ -94,7 +94,7 @@ export class EntryEditComponent {
9494

9595
private getUpdatedPost$(): Observable<EntryEditVm> {
9696
// Listen to the stream of submitted requests.
97-
return this.submittedRequestSubject.pipe(
97+
return this.submittedRequestSubject$.pipe(
9898
// Submit the first update and wait. All other requests are discarded.
9999
exhaustMap(request => this.blogService.updatePost(request.slug, request.body)),
100100
// When update is complete, re-fetch all possible categories.
@@ -122,6 +122,6 @@ export class EntryEditComponent {
122122
}
123123

124124
onPublish(slug: string, request: PostRequest): void {
125-
this.submittedRequestSubject.next({ slug, body: request });
125+
this.submittedRequestSubject$.next({ slug, body: request });
126126
}
127127
}

src/bhs-web-angular-app/src/app/features/blog/pages/entry-new/entry-new.component.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export class EntryNewComponent {
3333
private readonly route = inject(ActivatedRoute);
3434
private readonly authorService = inject(AuthorService);
3535

36-
private readonly submittedRequestSubject = new Subject<PostRequest>();
37-
private readonly routeErrorSubject = new Subject<{ newPost?: Post; error: unknown }>();
36+
private readonly submittedRequestSubject$ = new Subject<PostRequest>();
37+
private readonly routeErrorSubject$ = new Subject<{ newPost?: Post; error: unknown }>();
3838

3939
vm$ = merge(this.getInitialVm$(), this.getCreatedPost$(), this.getRouteError$()).pipe(
4040
startWith({ allCategories: [], isLoading: true } as EntryNewVm),
@@ -49,7 +49,7 @@ export class EntryNewComponent {
4949
);
5050

5151
onPublish(request: PostRequest): void {
52-
this.submittedRequestSubject.next(request);
52+
this.submittedRequestSubject$.next(request);
5353
}
5454

5555
private getInitialVm$(): Observable<EntryNewVm> {
@@ -63,7 +63,7 @@ export class EntryNewComponent {
6363

6464
return { currentAuthor, allCategories, isLoading: false };
6565
}),
66-
switchMap(vm => this.submittedRequestSubject.pipe(
66+
switchMap(vm => this.submittedRequestSubject$.pipe(
6767
map(() => true),
6868
startWith(false),
6969
map(isSubmitting => ({ ...vm, isLoading: isSubmitting })),
@@ -72,11 +72,11 @@ export class EntryNewComponent {
7272
}
7373

7474
private getCreatedPost$(): Observable<EntryNewVm> {
75-
return this.submittedRequestSubject.pipe(
75+
return this.submittedRequestSubject$.pipe(
7676
exhaustMap(request => this.blogService.createPost(request)),
7777
map(newPost => {
7878
this.router.navigate(['../entry', newPost.slug], { relativeTo: this.route })
79-
.catch((error: unknown) => { this.routeErrorSubject.next({ error, newPost }); });
79+
.catch((error: unknown) => { this.routeErrorSubject$.next({ error, newPost }); });
8080

8181
// Instead of mapping the post into the VM, just keep loading until the route changes.
8282
return { isLoading: true, allCategories: [], currentAuthor: null };
@@ -85,7 +85,7 @@ export class EntryNewComponent {
8585
}
8686

8787
private getRouteError$(): Observable<never> {
88-
return this.routeErrorSubject.pipe(
88+
return this.routeErrorSubject$.pipe(
8989
map(({ error, newPost }) => {
9090
let msg = `An error occurred while navigating to new post '${newPost?.title ?? newPost?.slug ?? '(null)'}'.`;
9191
if (typeof error === 'object' && error && 'message' in error && typeof error.message === 'string') {

0 commit comments

Comments
 (0)