當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript redux-thunk.Dispatch類代碼示例

本文整理匯總了TypeScript中redux-thunk.Dispatch的典型用法代碼示例。如果您正苦於以下問題:TypeScript Dispatch類的具體用法?TypeScript Dispatch怎麽用?TypeScript Dispatch使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Dispatch類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: async

export const getUsers = () => async (
  dispatch: Dispatch<Action>,
  getState: GetState
) => {
  try {
    const {
      members: {list},
    } = getState()

    const apiUsers = await client.users.getAll()
    const allUsers = apiUsers.reduce((acc, u) => _.set(acc, u.id, u), {})
    const users = _.omit(allUsers, list.map(m => m.id))

    dispatch(setUsers(RemoteDataState.Done, users))
  } catch (e) {
    console.error(e)
    dispatch(setMembers(RemoteDataState.Error))
  }
}
開發者ID:sebito91,項目名稱:influxdb,代碼行數:19,代碼來源:index.ts

示例2: async

export const getBuckets = () => async (
  dispatch: Dispatch<Action>,
  getState: () => AppState
) => {
  try {
    dispatch(setBuckets(RemoteDataState.Loading))
    const {
      orgs: {org},
    } = getState()

    const buckets = await client.buckets.getAll(org.id)

    dispatch(setBuckets(RemoteDataState.Done, buckets))
  } catch (e) {
    console.error(e)
    dispatch(setBuckets(RemoteDataState.Error))
    dispatch(notify(getBucketsFailed()))
  }
}
開發者ID:influxdata,項目名稱:influxdb,代碼行數:19,代碼來源:index.ts

示例3: async

) => async (dispatch: Dispatch<Action>, getState: GetState) => {
  try {
    const {
      orgs: {org},
    } = getState()
    const createdVariable = await createVariableFromTemplateAJAX(
      template,
      org.id
    )

    dispatch(
      setVariable(createdVariable.id, RemoteDataState.Done, createdVariable)
    )
    dispatch(notify(createVariableSuccess(createdVariable.name)))
  } catch (e) {
    console.error(e)
    dispatch(notify(createVariableFailed(e.response.data.message)))
  }
}
開發者ID:influxdata,項目名稱:influxdb,代碼行數:19,代碼來源:index.ts

示例4: async

export const getAuthorizations = () => async (
  dispatch: Dispatch<Action>,
  getState: () => AppState
) => {
  try {
    dispatch(setAuthorizations(RemoteDataState.Loading))
    const {
      orgs: {org},
    } = getState()

    const authorizations = await client.authorizations.getAll(org.id)

    dispatch(setAuthorizations(RemoteDataState.Done, authorizations))
  } catch (e) {
    console.error(e)
    dispatch(setAuthorizations(RemoteDataState.Error))
    dispatch(notify(authorizationsGetFailed()))
  }
}
開發者ID:sebito91,項目名稱:influxdb,代碼行數:19,代碼來源:index.ts

示例5: async

export const deleteMember = (member: Member) => async (
  dispatch: Dispatch<Action>,
  getState: GetState
) => {
  try {
    const {
      orgs: {
        org: {id},
      },
    } = getState()

    await client.organizations.removeMember(id, member.id)
    dispatch(removeMember(member.id))

    dispatch(notify(memberRemoveSuccess(member.name)))
  } catch (e) {
    console.error(e)
    dispatch(notify(memberRemoveFailed(member.name)))
  }
}
開發者ID:influxdata,項目名稱:influxdb,代碼行數:20,代碼來源:index.ts

示例6: async

export const createBucket = (bucket: Bucket) => async (
  dispatch: Dispatch<Action>,
  getState: () => AppState
) => {
  try {
    const {
      orgs: {org},
    } = getState()

    const createdBucket = await client.buckets.create({
      ...bucket,
      organizationID: org.id,
    })

    dispatch(addBucket(createdBucket))
  } catch (e) {
    console.error(e)
    dispatch(notify(bucketCreateFailed()))
    throw e
  }
}
開發者ID:sebito91,項目名稱:influxdb,代碼行數:21,代碼來源:index.ts

示例7: async

export const selectTagValue = (index: number, value: string) => async (
  dispatch: Dispatch<Action>,
  getState: GetState
) => {
  const tags = getActiveQuery(getState()).builderConfig.tags
  const values = tags[index].values

  let newValues: string[]

  if (values.includes(value)) {
    newValues = values.filter(v => v !== value)
  } else {
    newValues = [...values, value]
  }

  dispatch(setBuilderTagValuesSelection(index, newValues))

  if (index === tags.length - 1 && newValues.length) {
    dispatch(addTagSelector())
  } else {
    dispatch(loadTagSelector(index + 1))
  }
}
開發者ID:influxdata,項目名稱:influxdb,代碼行數:23,代碼來源:queryBuilder.ts

示例8: async

export const createNoteCell = (dashboardID: string) => async (
  dispatch: Dispatch<Action>,
  getState: GetState
) => {
  const dashboard = getState().dashboards.list.find(d => d.id === dashboardID)

  if (!dashboard) {
    throw new Error(`could not find dashboard with id "${dashboardID}"`)
  }

  const {note} = getState().noteEditor
  const view = createView<MarkdownView>(ViewType.Markdown)

  view.properties.note = note

  return dispatch(createCellWithView(dashboard, view))
}
開發者ID:influxdata,項目名稱:influxdb,代碼行數:17,代碼來源:notes.ts


注:本文中的redux-thunk.Dispatch類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。