can I pass observable as function parameter?

Can I pass observable to function as a parameter ? I have two observables that get data from backend and I need to filter them out by a lot of conditions. To do not repeat myself I thought about function that will filter observable data and return already filtered one. There will be couple of combineLatest inside as I will be reacting to action streams (values selected on UI). I came up with something like:

    const data1$ = this.service.getData('first');
    const data2$ = this.service.getData('second');

    filterData(input$: Observable<string>) : Observable<string> {

        const filtered$ = combineLatest(input$, this.service.selectedFiltersData$).pipe(...filtering...taping and so on...)
        const filteredBySomethingElse$(filtered$, this.service.anotherSelectedFilters.pipe(...filtering...taping and so on...)

      return filteredBySomethingElse$;

    const filtered1$ = this.filterData(data1$);
    const filtered2$ = this.filterData(data2$);

Example is extremely simplified :)
Is that a good practice ?

Read more here:

Content Attribution

This content was originally published by Mr.FloppyDisk at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: