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