Skip to content

Might be useful to have examples folder #72

Open
@quantuminformation

Description

It would be nice to have an examples folder with a real redux app with all the various ways this can be used and best practices, Esp async stuff.

My use case is that I'm trying to understand a codebase I've inherited and am not sure if this is a standard practice or not:

import { Site } from '../../model/Site';
import { loadSites as eventApiLoadSites } from '../../rest-api/Event-api';
import { Dispatch } from 'redux';
import { actionCreatorFactory, AnyAction } from 'typescript-fsa';
import wrapAsyncWorker from './wrapAsyncWorker';

const actionCreator = actionCreatorFactory();

export const LoadSites = actionCreator.async<null, Site[]>('LoadSites');

const loadSitesWorker =
  wrapAsyncWorker(LoadSites, (): Promise<Site[]> => eventApiLoadSites());

export const loadSites = () => {
  return (dispatch: Dispatch<AnyAction>) => loadSitesWorker(dispatch, null);
};

loadSites() is passed to an argument to store.dispatch and is giving me typing errors:

TypeScript error: Argument of type '(dispatch: Dispatch<AnyAction>) => Promise<Site[]>' is not assignable to parameter of type 'AnyAction'.

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