Skip to content

Commit

Permalink
refactor: improve typing
Browse files Browse the repository at this point in the history
  • Loading branch information
edbzn committed Nov 2, 2023
1 parent 97e75b7 commit 956efaa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions projects/todo-mvc/src/app/todo.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -27,11 +27,13 @@ export interface Actions {
setFilter: TodoFilter;
}

const completedTodos = (source: Observable<Todo[]>): Observable<Todo[]> =>
source.pipe(map((todos) => todos.filter((todo) => todo.done)));
const completedTodos: MonoTypeOperatorFunction<Todo[]> = (source) => {
return source.pipe(map((todos) => todos.filter((todo) => todo.done)));
}

const activeTodos = (source: Observable<Todo[]>): Observable<Todo[]> =>
source.pipe(map((todos) => todos.filter((todo) => !todo.done)));
const activeTodos: MonoTypeOperatorFunction<Todo[]> = (source) => {
return source.pipe(map((todos) => todos.filter((todo) => !todo.done)));
}

@Injectable()
export class TodoService {
Expand Down

0 comments on commit 956efaa

Please sign in to comment.