本文整理匯總了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
}
}