@reduxjs/toolkit#createAction TypeScript Examples

The following examples show how to use @reduxjs/toolkit#createAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: actions.ts    From cheeseswap-interface with GNU General Public License v3.0 6 votes vote down vote up
fetchTokenList: Readonly<{
  pending: ActionCreatorWithPayload<{ url: string; requestId: string }>
  fulfilled: ActionCreatorWithPayload<{ url: string; tokenList: TokenList; requestId: string }>
  rejected: ActionCreatorWithPayload<{ url: string; errorMessage: string; requestId: string }>
}> = {
  pending: createAction('lists/fetchTokenList/pending'),
  fulfilled: createAction('lists/fetchTokenList/fulfilled'),
  rejected: createAction('lists/fetchTokenList/rejected')
}
Example #2
Source File: saga.ts    From celo-web-wallet with MIT License 6 votes vote down vote up
/**
 * A convenience utility to create a saga and trigger action
 * Use to create simple sagas, for more complex ones use createMonitoredSaga.
 * Note: the wrapped saga this returns must be added to rootSaga.ts
 */
export function createSaga<SagaParams = void>(saga: (...args: any[]) => any, name: string) {
  const triggerAction = createAction<SagaParams>(`${name}/trigger`)

  const wrappedSaga = function* () {
    while (true) {
      try {
        const trigger: Effect = yield take(triggerAction.type)
        logger.debug(`${name} triggered`)
        yield call(saga, trigger.payload)
      } catch (error) {
        logger.error(`${name} error`, error)
      }
    }
  }

  return {
    wrappedSaga,
    trigger: triggerAction,
  }
}
Example #3
Source File: actions.ts    From interface-v2 with GNU General Public License v3.0 6 votes vote down vote up
fetchTokenList: Readonly<{
  pending: ActionCreatorWithPayload<{ url: string; requestId: string }>;
  fulfilled: ActionCreatorWithPayload<{
    url: string;
    tokenList: TokenList;
    requestId: string;
  }>;
  rejected: ActionCreatorWithPayload<{
    url: string;
    errorMessage: string;
    requestId: string;
  }>;
}> = {
  pending: createAction('lists/fetchTokenList/pending'),
  fulfilled: createAction('lists/fetchTokenList/fulfilled'),
  rejected: createAction('lists/fetchTokenList/rejected'),
}
Example #4
Source File: Actions.ts    From Teyvat.moe with GNU General Public License v3.0 5 votes vote down vote up
clearRouteGroupDisplayed = createAction<MSFRouteGroupKey>(
  `${REDUX_SLICE_DISPLAYED}/clearRouteGroupDisplayed`
)
Example #5
Source File: actions.ts    From sybil-interface with GNU General Public License v3.0 5 votes vote down vote up
updateBlockNumber = createAction<{ chainId: number; blockNumber: number }>('application/updateBlockNumber')
Example #6
Source File: walletConnectSlice.ts    From celo-web-wallet with MIT License 5 votes vote down vote up
approveWcSession = createAction('walletConnect/approveSession')
Example #7
Source File: actions.ts    From cheeseswap-interface with GNU General Public License v3.0 5 votes vote down vote up
rejectVersionUpdate = createAction<Version>('lists/rejectVersionUpdate')
Example #8
Source File: walletConnectSlice.ts    From celo-web-wallet with MIT License 5 votes vote down vote up
resetWcClient = createAction('walletConnect/reset')
Example #9
Source File: actions.ts    From sybil-interface with GNU General Public License v3.0 5 votes vote down vote up
checkedTransaction = createAction<{
  chainId: ChainId
  hash: string
  blockNumber: number
}>('transactions/checkedTransaction')
Example #10
Source File: reducer.ts    From your_spotify with GNU General Public License v3.0 5 votes vote down vote up
alertMessage = createAction<AlertMessage>('@message/create')
Example #11
Source File: walletConnectSlice.ts    From celo-web-wallet with MIT License 5 votes vote down vote up
proposeWcSession = createAction<SessionTypes.Proposal>('walletConnect/proposeSession')
Example #12
Source File: reducer.ts    From your_spotify with GNU General Public License v3.0 5 votes vote down vote up
setPublicToken = createAction<string | null>('@user/set-public-token')
Example #13
Source File: actions.ts    From sybil-interface with GNU General Public License v3.0 5 votes vote down vote up
updateTwitterAccount = createAction<{ twitterAccount: string | undefined }>('user/updateTwitterAccount')