本文整理汇总了TypeScript中src/types.GetState.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript GetState.default方法的具体用法?TypeScript GetState.default怎么用?TypeScript GetState.default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src/types.GetState
的用法示例。
在下文中一共展示了GetState.default方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: dispatch
export const saveVEOView = (dashboard: Dashboard) => async (
dispatch,
getState: GetState
): Promise<void> => {
const view = getSaveableView(getState())
try {
if (view.id) {
await dispatch(updateView(dashboard, view))
} else {
await dispatch(createCellWithView(dashboard, view))
}
} catch (error) {
console.error(error)
dispatch(notify(copy.cellAddFailed()))
}
}
示例2: async
export const getTelegrafs = () => async (dispatch, getState: GetState) => {
const {
orgs: {org},
} = getState()
try {
dispatch(setTelegrafs(RemoteDataState.Loading))
const telegrafs = await client.telegrafConfigs.getAll(org.id)
dispatch(setTelegrafs(RemoteDataState.Done, telegrafs))
} catch (e) {
console.error(e)
dispatch(setTelegrafs(RemoteDataState.Error))
dispatch(notify(telegrafGetFailed()))
}
}
示例3: async
) => async (dispatch: Dispatch<Action>, getState: GetState) => {
const {
orgs: {org},
} = getState()
try {
const createdLabel = await client.labels.create({
orgID: org.id,
name,
properties,
})
dispatch(addLabel(createdLabel))
} catch (e) {
console.error(e)
dispatch(notify(createLabelFailed()))
}
}
示例4: async
export const getVariables = () => async (
dispatch: Dispatch<Action>,
getState: GetState
) => {
try {
dispatch(setVariables(RemoteDataState.Loading))
const {
orgs: {org},
} = getState()
const variables = await client.variables.getAll(org.id)
dispatch(setVariables(RemoteDataState.Done, variables))
} catch (e) {
console.error(e)
dispatch(setVariables(RemoteDataState.Error))
dispatch(notify(getVariablesFailed()))
}
}
示例5: async
export const getAuthorizations = () => async (
dispatch: Dispatch<Action | NotificationAction>,
getState: GetState
) => {
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()))
}
}
示例6: 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))
}
}
示例7: async
export const getScrapers = () => async (
dispatch: Dispatch<Action>,
getState: GetState
) => {
try {
const {
orgs: {org},
} = getState()
dispatch(setScrapers(RemoteDataState.Loading))
const scrapers = await client.scrapers.getAll(org.id)
dispatch(setScrapers(RemoteDataState.Done, scrapers))
} catch (e) {
console.error(e)
dispatch(setScrapers(RemoteDataState.Error))
}
}
示例8: async
export const getDashboardsAsync = () => async (
dispatch: Dispatch<Action>,
getState: GetState
): Promise<Dashboard[]> => {
try {
const {
orgs: {org},
} = getState()
dispatch(setDashboards(RemoteDataState.Loading))
const dashboards = await getDashboardsAJAX(org.id)
dispatch(setDashboards(RemoteDataState.Done, dashboards))
return dashboards
} catch (error) {
dispatch(setDashboards(RemoteDataState.Error))
console.error(error)
throw error
}
}