本文整理匯總了TypeScript中typescript-fsa.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: actionCreatorFactory
import actionCreatorFactory from "typescript-fsa";
import { reducerWithInitialState } from "typescript-fsa-reducers";
import tabs, { TabId } from "../tabs";
export default interface Sidebar {
activeTabId: TabId;
expanded: boolean;
}
export const SAFE_INIT: Sidebar = {
activeTabId: "lar",
expanded: true,
};
const actionCreator = actionCreatorFactory("SIDEBAR");
export const activateTab = actionCreator<TabId>("ACTIVATE");
export const collapse = actionCreator("COLLAPSE");
export const expand = actionCreator("EXPAND");
export const reducer = reducerWithInitialState(SAFE_INIT)
.case(
activateTab,
(original: Sidebar, activeTabId: TabId) => ({ ...original, activeTabId }),
).case(
collapse,
(original: Sidebar) => ({ ...original, expanded: false }),
).case(
expand,
(original: Sidebar) => ({ ...original, expanded: true }),
示例2: actionCreatorFactory
longitude: number;
zoom: number;
}
export default interface Viewport extends StaticViewport {
transitionDuration: number;
}
export const SAFE_INIT: Viewport = {
latitude: 41.88,
longitude: -87.64,
transitionDuration: 0,
zoom: 12,
};
const actionCreator = actionCreatorFactory("VIEWPORT");
export const setViewport = actionCreator<StaticViewport>("SET");
export const transitionViewport = actionCreator<StaticViewport>("TRANSITION");
export const reducer = reducerWithInitialState(SAFE_INIT)
.case(setViewport, (_, { latitude, longitude, zoom }) => ({
latitude,
longitude,
transitionDuration: 0,
zoom: Math.min(zoom, 12),
}))
.case(transitionViewport, (_, { latitude, longitude, zoom }) => ({
latitude,
longitude,
transitionDuration: 3000,
示例3: actionCreatorFactory
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import actionCreatorFactory from 'typescript-fsa';
import { FilterQuery } from './reducer';
const actionCreator = actionCreatorFactory('x-pack/infra/local/waffle_filter');
export const setWaffleFilterQueryDraft = actionCreator<FilterQuery>(
'SET_WAFFLE_FILTER_QUERY_DRAFT'
);
export const applyWaffleFilterQuery = actionCreator<FilterQuery>('APPLY_WAFFLE_FILTER_QUERY');
示例4: actionCreatorFactory
import actionCreatorFactory from 'typescript-fsa';
export const actionCreator = actionCreatorFactory(`@@manager/images`);
export const getImagesRequest = actionCreator(`request`);
export const getImagesSuccess = actionCreator<Linode.Image[]>(`success`);
export const getImagesFailure = actionCreator<Linode.ApiFieldError[]>(`fail`);
export const removeImage = actionCreator<number | string>(`remove`);
export const addOrUpdateImage = actionCreator<Linode.Image>('add_or_update');
示例5: actionCreatorFactory
import actionCreatorFactory from 'typescript-fsa';
const actionCreator = actionCreatorFactory(`@@manager/types`);
export const getLinodeTypesActions = actionCreator.async<
void,
Linode.LinodeType[],
Linode.ApiFieldError[]
>(`request`);
示例6: actionCreatorFactory
}
interface AddRemoveFilter {
county?: GeoId;
lender?: LenderId;
metro?: GeoId;
}
export const SAFE_INIT: Filters = {
...homePurchasePreset,
county: Set<GeoId>(),
lender: Set<LenderId>(),
metro: Set<GeoId>(),
year: NaN,
};
const actionCreator = actionCreatorFactory("LAR/FILTERS");
const asyncActionCreator = asyncFactory<Filters>(actionCreator);
export const addFilter = actionCreator<AddRemoveFilter>("ADD_FILTER");
export const removeFilter = actionCreator<AddRemoveFilter>("REMOVE_FILTER");
export const setFilters = actionCreator<Partial<Filters>>("SET_FILTERS");
export const zoomToGeos = asyncActionCreator<void, void>(
"ZOOM_TO_GEOS",
(_, dispatch, getState: () => any) => {
const { lar, window: { height, width } } = getState();
const { filters, lookups } = lar;
const geos = filters.county.toArray().map(id => lookups.geos.get(id))
.concat(filters.metro.toArray().map(id => lookups.geos.get(id)));
if (geos.length) {
示例7: actionCreatorFactory
import actionCreatorFactory from 'typescript-fsa';
import { ExtendedEvent } from './event.helpers';
type Event = ExtendedEvent;
export const ADD_EVENTS = `ADD_EVENTS`;
export const UPDATE_EVENTS_AS_SEEN = `UPDATE_EVENTS_AS_SEEN`;
export const actionCreator = actionCreatorFactory(`@@manager/events`);
export const addEvents = actionCreator<Event[]>(ADD_EVENTS);
export const updateEventsAsSeen = actionCreator(UPDATE_EVENTS_AS_SEEN);
示例8: actionCreatorFactory
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import actionCreatorFactory from 'typescript-fsa';
import { HostsSortField } from '../../graphql/types';
import { KueryFilterQuery, SerializedFilterQuery } from '../model';
import { HostsType } from './model';
const actionCreator = actionCreatorFactory('x-pack/siem/local/hosts');
export const updateAuthenticationsLimit = actionCreator<{ limit: number; hostsType: HostsType }>(
'UPDATE_AUTHENTICATIONS_LIMIT'
);
export const updateHostsLimit = actionCreator<{ limit: number; hostsType: HostsType }>(
'UPDATE_HOSTS_LIMIT'
);
export const updateHostsSort = actionCreator<{
sort: HostsSortField;
hostsType: HostsType;
}>('UPDATE_HOSTS_SORT');
export const updateEventsLimit = actionCreator<{ limit: number; hostsType: HostsType }>(
'UPDATE_EVENTS_LIMIT'
);
示例9: actionCreatorFactory
import { Dispatch } from 'redux';
import actionCreatorFactory from 'typescript-fsa';
import { asyncFactory } from 'typescript-fsa-redux-thunk';
import { RootState } from './reducer';
const create = actionCreatorFactory();
const createAsync = asyncFactory<RootState>(create as any);
export function promiseAction<Returns, ActionParams = {}, Error = {}>(
// tslint:disable-next-line:no-any
name: string, func: (params: ActionParams, dispatch?: Dispatch, getState?: any, extraArg?: any) => Promise<Returns>
) {
return createAsync<ActionParams, Returns, Error>(name, func);
}
示例10: actionCreatorFactory
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import actionCreatorFactory from 'typescript-fsa';
const actionCreator = actionCreatorFactory('x-pack/infra/local/metric_time');
export interface MetricRangeTimeState {
to: number;
from: number;
interval: string;
}
export const setRangeTime = actionCreator<MetricRangeTimeState>('SET_RANGE_TIME');
export const startMetricsAutoReload = actionCreator('START_METRICS_AUTO_RELOAD');
export const stopMetricsAutoReload = actionCreator('STOP_METRICS_AUTO_RELOAD');