From 956efaaad39e0ae232cabeefe863516cf06c2694 Mon Sep 17 00:00:00 2001 From: Edouard Bozon Date: Thu, 2 Nov 2023 09:32:28 +0100 Subject: [PATCH] refactor: improve typing --- projects/todo-mvc/src/app/todo.service.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/projects/todo-mvc/src/app/todo.service.ts b/projects/todo-mvc/src/app/todo.service.ts index 2fbb539..c292204 100644 --- a/projects/todo-mvc/src/app/todo.service.ts +++ b/projects/todo-mvc/src/app/todo.service.ts @@ -1,5 +1,5 @@ import { inject, Injectable } from '@angular/core'; -import { forkJoin, merge, Observable } from 'rxjs'; +import { forkJoin, merge, MonoTypeOperatorFunction } from 'rxjs'; import { exhaustMap, map, withLatestFrom } from 'rxjs/operators'; import { rxState } from '@rx-angular/state'; import { rxActions } from '@rx-angular/state/actions'; @@ -27,11 +27,13 @@ export interface Actions { setFilter: TodoFilter; } -const completedTodos = (source: Observable): Observable => - source.pipe(map((todos) => todos.filter((todo) => todo.done))); +const completedTodos: MonoTypeOperatorFunction = (source) => { + return source.pipe(map((todos) => todos.filter((todo) => todo.done))); +} -const activeTodos = (source: Observable): Observable => - source.pipe(map((todos) => todos.filter((todo) => !todo.done))); +const activeTodos: MonoTypeOperatorFunction = (source) => { + return source.pipe(map((todos) => todos.filter((todo) => !todo.done))); +} @Injectable() export class TodoService {