Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error while trying to dispatch an Observable #161

Open
dvkvarma opened this issue Jul 14, 2020 · 0 comments
Open

Type Error while trying to dispatch an Observable #161

dvkvarma opened this issue Jul 14, 2020 · 0 comments

Comments

@dvkvarma
Copy link

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 | });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant