How to use the typesafe-actions.createAsyncAction function in typesafe-actions

To help you get started, we’ve selected a few typesafe-actions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sharedstreets / sharedstreets-road-closure-ui / src / store / road-closure / index.ts View on Github external
'ROAD_CLOSURE/FETCH_SHAREDSTREET_GEOMS_SUCCESS',
        'ROAD_CLOSURE/FETCH_SHAREDSTREET_GEOMS_FAILURE'
    )(),
    FILE_ADDED: createStandardAction('ROAD_CLOSURE/FILE_ADDED')(),
    GENERATE_SHAREDSTREETS_PUBLIC_DATA_UPLOAD_URL: createAsyncAction(
        'ROAD_CLOSURE/GENERATE_SHAREDSTREETS_PUBLIC_DATA_UPLOAD_URL_REQUEST',
        'ROAD_CLOSURE/GENERATE_SHAREDSTREETS_PUBLIC_DATA_UPLOAD_URL_SUCCESS',
        'ROAD_CLOSURE/GENERATE_SHAREDSTREETS_PUBLIC_DATA_UPLOAD_URL_FAILURE'
    )(),
    HIGHLIGHT_MATCHED_STREET: createStandardAction('ROAD_CLOSURE/HIGHLIGHT_MATCHED_STREET')(),
    HIGHLIGHT_MATCHED_STREETS_GROUP: createStandardAction('ROAD_CLOSURE/HIGHLIGHT_MATCHED_STREETS_GROUP')(),
    INPUT_CHANGED: createStandardAction('ROAD_CLOSURE/INPUT_CHANGED')(),
    INPUT_REMOVED: createStandardAction('ROAD_CLOSURE/INPUT_REMOVED')(),
    LOAD_ALL_ORGS: createStandardAction('ROAD_CLOSURE/LOAD_ALL_ORGS')<{ [name: string]: IRoadClosureOrgName }>(),
    LOAD_INPUT: createStandardAction('ROAD_CLOSURE/LOAD_INPUT')(),
    PUT_SHAREDSTREETS_PUBLIC_DATA: createAsyncAction(
        'ROAD_CLOSURE/PUT_SHAREDSTREETS_PUBLIC_DATA_REQUEST',
        'ROAD_CLOSURE/PUT_SHAREDSTREETS_PUBLIC_DATA_SUCCESS',
        'ROAD_CLOSURE/PUT_SHAREDSTREETS_PUBLIC_DATA_FAILURE'
    )(),
    RESET_ROAD_CLOSURE: createStandardAction('ROAD_CLOSURE/RESET_ROAD_CLOSURE')(),
    ROAD_CLOSURE_HIDE_OUTPUT: createStandardAction('ROAD_CLOSURE/ROAD_CLOSURE_HIDE_OUTPUT')(),
    ROAD_CLOSURE_VIEW_OUTPUT: createStandardAction('ROAD_CLOSURE/ROAD_CLOSURE_VIEW_OUTPUT')(),
    SAVED_OUTPUT: createStandardAction('ROAD_CLOSURE/SAVED_OUTPUT')(),
    SAVING_OUTPUT: createStandardAction('ROAD_CLOSURE/SAVING_OUTPUT')(),
    SELECT_OUTPUT_FORMAT: createStandardAction('ROAD_CLOSURE/SELECT_OUTPUT_FORMAT')(),
    TOGGLE_DIRECTION_STREET_SEGMENT: createStandardAction('ROAD_CLOSURE/TOGGLE_DIRECTION_STREET_SEGMENT')(),
    VIEWPORT_CHANGED: createStandardAction('ROAD_CLOSURE/VIEWPORT_CHANGED'),
    ZOOM_HIGHLIGHT_MATCHED_STREETS_GROUP: createStandardAction('ROAD_CLOSURE/ZOOM_HIGHLIGHT_MATCHED_STREETS_GROUP')(),
};

// side effects
github OfficeDev / script-lab / client / src / store / gists / actions.ts View on Github external
import { createAsyncAction } from 'typesafe-actions'
import { ConflictResolutionOptions } from '../../interfaces/enums'

// used for import
export const importSnippet = createAsyncAction(
  'IMPORT_GIST_REQUEST',
  'IMPORT_GIST_SUCCESS',
  'IMPORT_GIST_FAILURE',
)<{ gistId?: string; gist?: string }, { solution: ISolution }, Error>()

export const create = createAsyncAction(
  'CREATE_GIST_REQUEST',
  'CREATE_GIST_SUCCESS',
  'CREATE_GIST_FAILURE',
)<
  { solutionId: string; isPublic: boolean },
  { gist: IGithubGistPayload; solution: ISolution },
  Error
>()

export const update = createAsyncAction(
github holochain / holochain-ui / ui-src / src / utils / holochainWebsocketActions.ts View on Github external
export function createHolochainAsyncAction (dnaHash: string, zome: string, capability: string, func: string) {
  const action = createAsyncAction(
    `${dnaHash}/${zome}/${func}`,
    `${dnaHash}/${zome}/${func}_FULFILLED`,
    `${dnaHash}/${zome}/${func}_REJECTED`)
  , returnType, Error>()

  const newAction = action as (typeof action & {
    create: (param: paramType) => any
    sig: (param: paramType) => Promise<{payload: returnType}>
  })
  newAction.create = (param: paramType) => action.request(
    connect('ws://localhost:4000/').then(({ call }) => {
      return call(dnaHash, zome, capability, func)(param)
    })
  )
  return newAction
}
github mikerourke / toggl-to-clockify-web / src / redux / entities / projects / projectsActions.ts View on Github external
TogglProjectUserModel,
} from "~/types";

export const clockifyProjectsFetch = createAsyncAction(
  "@projects/CLOCKIFY_FETCH_REQUEST",
  "@projects/CLOCKIFY_FETCH_SUCCESS",
  "@projects/CLOCKIFY_FETCH_FAILURE",
), void>();

export const togglProjectsFetch = createAsyncAction(
  "@projects/TOGGL_FETCH_REQUEST",
  "@projects/TOGGL_FETCH_SUCCESS",
  "@projects/TOGGL_FETCH_FAILURE",
), void>();

export const clockifyProjectsTransfer = createAsyncAction(
  "@projects/CLOCKIFY_TRANSFER_REQUEST",
  "@projects/CLOCKIFY_TRANSFER_SUCCESS",
  "@projects/CLOCKIFY_TRANSFER_FAILURE",
), void>();

export const flipIsProjectIncluded = createAction("@projects/FLIP_IS_INCLUDED")<
  string
>();

export const fetchClockifyProjects = (workspaceId: string) => async (
  dispatch: ReduxDispatch,
) => {
  dispatch(clockifyProjectsFetch.request());
  try {
    const projects = await paginatedFetch({
      apiFetchFunc: apiFetchClockifyProjects,
github textileio / photos / App / Redux / UIRedux.ts View on Github external
return (error: Error, message?: string) => resolve({ error, message })
  }),
  dismissImagePickerError: createAction(
    'DISMISS_IMAGE_PICKER_ERROR',
    resolve => {
      return () => resolve()
    }
  ),
  routeDeepLinkRequest: createAction('ROUTE_DEEP_LINK_REQUEST', resolve => {
    return (url: string) => resolve({ url })
  }),
  addFriendRequest: createAction('ADD_FRIEND_REQUEST', resolve => {
    return (threadId: string, threadName: string) =>
      resolve({ threadId, threadName })
  }),
  addLike: createAsyncAction(
    'ADD_LIKE_REQUEST',
    'ADD_LIKE_SUCCESS',
    'ADD_LIKE_FAILURE'
  )<
    { blockId: string },
    { blockId: string },
    { blockId: string; error: any }
  >(),
  navigateToThreadRequest: createAction(
    'NAVIGATE_TO_THREAD_REQUEST',
    resolve => {
      return (threadId: string, threadName: string) =>
        resolve({ threadId, threadName })
    }
  ),
  navigateToCommentsRequest: createAction(
github csprance / MisRCON / src / redux / servers / actions.ts View on Github external
const server = serverByIdSelector(getState(), { id });
    if (server) {
      dispatch(getServerDataThunk(server));
      dispatch(markServerActive.success());
    } else {
      dispatch(markServerActive.failure('Server Not Found'));
    }
  } catch (err) {
    dispatch(markServerActive.failure(err.toString()));
  }
};

/*
Get the whitelist status for the active server
 */
export const getWhitelistStatus = createAsyncAction(
  'server/GET_WHITELIST_STATUS_REQUEST',
  'server/GET_WHITELIST_STATUS_SUCCESS',
  'server/GET_WHITELIST_STATUS_FAILED'
)();
export const getWhitelistStatusThunk = (): AsyncThunkResult => async (
  dispatch,
  getState
) => {
  dispatch(getWhitelistStatus.request());
  try {
    const request = {
      ...activeServerCredentialsSelector(getState()),
      command: 'mis_whitelist_status',
      id: activeServerIDSelector(getState())
    };
    await dispatch(sendRCONAsyncThunk(request));
github sharedstreets / sharedstreets-road-closure-ui / src / store / road-closure / index.ts View on Github external
}

export const ROAD_CLOSURE_ACTIONS = {
    DELETE_STREET_SEGMENT: createStandardAction('ROAD_CLOSURE/DELETE_STREET_SEGMENT')(),
    FETCH_SHAREDSTREETS_MATCH_POINT: createAsyncAction(
        'ROAD_CLOSURE/FETCH_SHAREDSTREETS_MATCH_POINT_REQUEST',
        'ROAD_CLOSURE/FETCH_SHAREDSTREETS_MATCH_POINT_SUCCESS',
        'ROAD_CLOSURE/FETCH_SHAREDSTREETS_MATCH_POINT_FAILURE'
    )(),
    FETCH_SHAREDSTREETS_MATCH_POINT_CANCEL: createStandardAction('ROAD_CLOSURE/FETCH_SHAREDSTREETS_MATCH_POINT_CANCEL')(),
    FETCH_SHAREDSTREETS_PUBLIC_DATA: createAsyncAction(
        'ROAD_CLOSURE/FETCH_SHAREDSTREETS_PUBLIC_DATA_REQUEST',
        'ROAD_CLOSURE/FETCH_SHAREDSTREETS_PUBLIC_DATA_SUCCESS',
        'ROAD_CLOSURE/FETCH_SHAREDSTREETS_PUBLIC_DATA_FAILURE'
    )(),
    FETCH_SHAREDSTREET_GEOMS: createAsyncAction(
        'ROAD_CLOSURE/FETCH_SHAREDSTREET_GEOMS_REQUEST',
        'ROAD_CLOSURE/FETCH_SHAREDSTREET_GEOMS_SUCCESS',
        'ROAD_CLOSURE/FETCH_SHAREDSTREET_GEOMS_FAILURE'
    )(),
    FILE_ADDED: createStandardAction('ROAD_CLOSURE/FILE_ADDED')(),
    GENERATE_SHAREDSTREETS_PUBLIC_DATA_UPLOAD_URL: createAsyncAction(
        'ROAD_CLOSURE/GENERATE_SHAREDSTREETS_PUBLIC_DATA_UPLOAD_URL_REQUEST',
        'ROAD_CLOSURE/GENERATE_SHAREDSTREETS_PUBLIC_DATA_UPLOAD_URL_SUCCESS',
        'ROAD_CLOSURE/GENERATE_SHAREDSTREETS_PUBLIC_DATA_UPLOAD_URL_FAILURE'
    )(),
    HIGHLIGHT_MATCHED_STREET: createStandardAction('ROAD_CLOSURE/HIGHLIGHT_MATCHED_STREET')(),
    HIGHLIGHT_MATCHED_STREETS_GROUP: createStandardAction('ROAD_CLOSURE/HIGHLIGHT_MATCHED_STREETS_GROUP')(),
    INPUT_CHANGED: createStandardAction('ROAD_CLOSURE/INPUT_CHANGED')(),
    INPUT_REMOVED: createStandardAction('ROAD_CLOSURE/INPUT_REMOVED')(),
    LOAD_ALL_ORGS: createStandardAction('ROAD_CLOSURE/LOAD_ALL_ORGS')<{ [name: string]: IRoadClosureOrgName }>(),
    LOAD_INPUT: createStandardAction('ROAD_CLOSURE/LOAD_INPUT')(),
github OfficeDev / script-lab / packages / editor / src / store / directScriptExecution / actions.ts View on Github external
resolve => {
    return (metadata: IDirectScriptExecutionFunctionMetadata[]) => resolve(metadata);
  },
);

export const runFunction = createAsyncAction(
  'DEFAULT_RUN_RUN_FUNCTION_REQUEST',
  'DEFAULT_RUN_RUN_FUNCTION_SUCCESS',
  'DEFAULT_RUN_RUN_FUNCTION_FAILURE',
)<
  { solutionId: string; fileId: string; functionName: string },
  { functionName: string; result: any },
  { functionName: string; error: Error }
>();

export const terminateAll = createAsyncAction(
  'DEFAULT_RUN_TERMINATE_ALL_REQUEST',
  'DEFAULT_RUN_TERMINATE_ALL_SUCCESS',
  'DEFAULT_RUN_TERMINATE_ALL_FAILURE',
)();
github mikerourke / toggl-to-clockify-web / src / redux / entities / users / usersActions.ts View on Github external
ClockifyUserModel,
  EntitiesFetchPayloadModel,
  EntityGroup,
  ReduxDispatch,
  ReduxGetState,
  TogglUserModel,
  ToolName,
} from "~/types";

export const clockifyUsersFetch = createAsyncAction(
  "@users/CLOCKIFY_FETCH_REQUEST",
  "@users/CLOCKIFY_FETCH_SUCCESS",
  "@users/CLOCKIFY_FETCH_FAILURE",
), void>();

export const togglUsersFetch = createAsyncAction(
  "@users/TOGGL_FETCH_REQUEST",
  "@users/TOGGL_FETCH_SUCCESS",
  "@users/TOGGL_FETCH_FAILURE",
), void>();

export const clockifyUsersTransfer = createAsyncAction(
  "@users/CLOCKIFY_TRANSFER_REQUEST",
  "@users/CLOCKIFY_TRANSFER_SUCCESS",
  "@users/CLOCKIFY_TRANSFER_FAILURE",
), void>();

export const flipIsUserIncluded = createAction("@users/FLIP_IS_INCLUDED")<
  string
>();

export const fetchClockifyUsers = (workspaceId: string) => async (
github intraxia / wp-gistpen / client / block / actions.ts View on Github external
'APPEND_BLOB_SUCCEEDED',
  'APPEND_BLOB_FAILED',
)();

export const saveBlob = createAsyncAction(
  'SAVE_BLOB_REQUESTED',
  'SAVE_BLOB_SUCCEEDED',
  'SAVE_BLOB_FAILED',
)();

export const newBlobAttached = createAction(
  'NEW_BLOB_ATTACHED',
  resolve => (blobId: number, repoId: number) => resolve({ blobId, repoId }),
);

export const createRepo = createAsyncAction(
  'CREATE_REPO_REQUESTED',
  'CREATE_REPO_SUCCEEDED',
  'CREATE_REPO_FAILED',
)();

export const newRepoCreated = createAction(
  'NEW_REPO_CREATED',
  resolve => (repo: ApiRepo) => resolve({ repo }),
);

export const embedSet = createAction(
  'EMBED_SET',
  resolve => (repoId: number, blobId: number) => resolve({ repoId, blobId }),
);