Skip to content

Type Error while trying to dispatch an Observable #161

Open
@dvkvarma

Description

@dvkvarma

Trying to dispatch an Observable

export const fetchMetaDataLogic: Logic = createLogic({
    type: fetchMetaData,
    process: ({ getState, action }, dispatch, done) => {
        const code: string = action.payload;
        const ob$ = new Observable(obs => {
            Promise.all([
                apiService.get(code)
                    .then((resp: AxiosResponse) => resp.data),
                apiService.getMeta()
                    .then((resp: AxiosResponse) => resp.data)
            ]).then(values => obs.complete()); // values dispatched
        });
        dispatch(ob$);
        done();
    }
});

Getting the Following Error.

Argument of type 'Observable<unknown>' is not assignable to parameter of type 'ArgumentAction<string, undefined, undefined>'.
  Type 'Observable<unknown>' is not assignable to type 'ActionBasis<string> & Partial<ActionBasis<string> & { payload: object; } & { meta: object; } & { error?: false | undefined; }>'.
    Property 'type' is missing in type 'Observable<unknown>' but required in type 'ActionBasis<string>'.  TS2345

    46 |             ]).then(values => obs.complete()); // values dispatched
    47 |         });
  > 48 |         dispatch(ob$);
       |                  ^
    49 |         done();
    50 |     }
    51 | });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions