import { ofType } from 'redux-observable';
import { concat, of } from 'rxjs';
import { concatMap } from 'rxjs/operators';

import { searchVideoAction } from '../slices';
import { queryAction, searchEventAction } from '@/modules/editorial/editorialSearch/reduxSearch/slices';

export default (action$) =>
  action$.pipe(
    ofType(searchVideoAction.type),
    concatMap(({ payload }) => concat(of(queryAction(payload)), of(searchEventAction()))),
  );
