• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript redux-thunk.Dispatch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript redux-thunk.ThunkDispatch类代码示例发布时间:2022-05-25
下一篇:
TypeScript redux-thunk.withExtraArgument函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap