本文整理汇总了TypeScript中lodash/isPlainObject.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: as
/**
* Decorates a component as a dragsource
* @param type The dragsource type
* @param spec The drag source specification
* @param collect The props collector function
* @param options DnD optinos
*/
export default function DragSource<Props, CollectedProps = {}, DragObject = {}>(
type: SourceType | ((props: Props) => SourceType),
spec: DragSourceSpec<Props, DragObject>,
collect: DragSourceCollector<CollectedProps>,
options: DndOptions<Props> = {},
) {
checkDecoratorArguments(
'DragSource',
'type, spec, collect[, options]',
type,
spec,
collect,
options,
)
let getType: ((props: Props) => SourceType) = type as ((
props: Props,
) => SourceType)
if (typeof type !== 'function') {
invariant(
isValidType(type),
'Expected "type" provided as the first argument to DragSource to be ' +
'a string, or a function that returns a string given the current props. ' +
'Instead, received %s. ' +
'Read more: http://react-dnd.github.io/react-dnd/docs-drag-source.html',
type,
)
getType = () => type
}
invariant(
isPlainObject(spec),
'Expected "spec" provided as the second argument to DragSource to be ' +
'a plain object. Instead, received %s. ' +
'Read more: http://react-dnd.github.io/react-dnd/docs-drag-source.html',
spec,
)
const createSource = createSourceFactory(spec)
invariant(
typeof collect === 'function',
'Expected "collect" provided as the third argument to DragSource to be ' +
'a function that returns a plain object of props to inject. ' +
'Instead, received %s. ' +
'Read more: http://react-dnd.github.io/react-dnd/docs-drag-source.html',
collect,
)
invariant(
isPlainObject(options),
'Expected "options" provided as the fourth argument to DragSource to be ' +
'a plain object when specified. ' +
'Instead, received %s. ' +
'Read more: http://react-dnd.github.io/react-dnd/docs-drag-source.html',
collect,
)
return function decorateSource<
TargetClass extends
| React.ComponentClass<Props>
| React.StatelessComponent<Props>
>(DecoratedComponent: TargetClass): TargetClass & DndComponentClass<Props> {
return decorateHandler<Props, TargetClass, SourceType>({
containerDisplayName: 'DragSource',
createHandler: createSource,
registerHandler: registerSource,
createMonitor: createSourceMonitor,
createConnector: createSourceConnector,
DecoratedComponent,
getType,
collect,
options,
})
}
}
开发者ID:chenermeng,项目名称:react-dnd,代码行数:78,代码来源:DragSource.ts
示例2: DragSource
export default function DragSource(
type: ItemType,
spec: IDragSourceSpecification<any, any>,
collect: DragSourceCollector<any>,
options: IDragSourceOptions = {},
) {
checkDecoratorArguments(
'DragSource',
'type, spec, collect[, options]',
type,
spec,
collect,
options, // eslint-disable-line prefer-rest-params
)
let getType: any = type
if (typeof type !== 'function') {
invariant(
isValidType(type),
'Expected "type" provided as the first argument to DragSource to be ' +
'a string, or a function that returns a string given the current props. ' +
'Instead, received %s. ' +
'Read more: http://react-dnd.github.io/react-dnd/docs-drag-source.html',
type,
)
getType = () => type
}
invariant(
isPlainObject(spec),
'Expected "spec" provided as the second argument to DragSource to be ' +
'a plain object. Instead, received %s. ' +
'Read more: http://react-dnd.github.io/react-dnd/docs-drag-source.html',
spec,
)
const createSource = createSourceFactory(spec)
invariant(
typeof collect === 'function',
'Expected "collect" provided as the third argument to DragSource to be ' +
'a function that returns a plain object of props to inject. ' +
'Instead, received %s. ' +
'Read more: http://react-dnd.github.io/react-dnd/docs-drag-source.html',
collect,
)
invariant(
isPlainObject(options),
'Expected "options" provided as the fourth argument to DragSource to be ' +
'a plain object when specified. ' +
'Instead, received %s. ' +
'Read more: http://react-dnd.github.io/react-dnd/docs-drag-source.html',
collect,
)
return function decorateSource<
Props,
T extends React.ComponentClass<Props> | React.StatelessComponent<Props>
>(DecoratedComponent: T): T & IDndComponentClass<Props> {
return decorateHandler({
connectBackend: (backend: IBackend, sourceId: string) => {
backend.connectDragSource(sourceId)
},
containerDisplayName: 'DragSource',
createHandler: createSource,
registerHandler: registerSource,
createMonitor: createSourceMonitor,
createConnector: createSourceConnector,
DecoratedComponent,
getType,
collect,
options,
}) as any
}
}
开发者ID:Shintaroa,项目名称:react-dnd,代码行数:71,代码来源:DragSource.ts
示例3: beginDrag
public beginDrag() {
const item = spec.beginDrag(this.props, this.monitor, this.component)
if (process.env.NODE_ENV !== 'production') {
invariant(
isPlainObject(item),
'beginDrag() must return a plain object that represents the dragged item. ' +
'Instead received %s. ' +
'Read more: http://react-dnd.github.io/react-dnd/docs-drag-source.html',
item,
)
}
return item
}
开发者ID:Shintaroa,项目名称:react-dnd,代码行数:13,代码来源:createSourceFactory.ts
示例4: drop
public drop() {
if (!spec.drop) {
return undefined
}
const dropResult = spec.drop(this.props, this.monitor, this.component)
if (process.env.NODE_ENV !== 'production') {
invariant(
typeof dropResult === 'undefined' || isPlainObject(dropResult),
'drop() must either return undefined, or an object that represents the drop result. ' +
'Instead received %s. ' +
'Read more: http://react-dnd.github.io/react-dnd/docs-drop-target.html',
dropResult,
)
}
return dropResult
}
开发者ID:Shintaroa,项目名称:react-dnd,代码行数:17,代码来源:createTargetFactory.ts
示例5: createStore
export const createArkhamStore = (configuration: ArkhamReduxStoreType): Store<any> => {
const {
arkhamMiddleware: middleware = [],
flux,
reducers,
sagas,
statePath = '',
reduxMiddleware = [],
devTools
} = configuration;
// Save initial state tree
const {storage} = Flux.getOptions();
let store: Store;
if(storage) {
const cachedState = Flux.getState(statePath);
if(devTools) {
store = createStore(
devTools(reducers, cachedState),
applyMiddleware(...reduxMiddleware, arkhamMiddleware(statePath, flux)));
} else {
store = createStore(
reducers,
cachedState,
applyMiddleware(...reduxMiddleware, arkhamMiddleware(statePath, flux)));
}
if(cachedState === undefined) {
const stateTree = store.getState();
const updatedState = isPlainObject(stateTree) ? merge(stateTree, cachedState) : stateTree;
Flux.setState(statePath, updatedState);
}
} else {
store = createStore(
reducers,
devTools,
applyMiddleware(...reduxMiddleware, arkhamMiddleware(statePath, flux))
);
Flux.setState(statePath, store.getState());
}
// If saga is being added, run.
reduxMiddleware.every((item: any) => {
if(sagas) {
item.run(sagas);
return false;
}
return true;
});
// Add redux middleware to Arkham to relay dispatches to Redux
middleware.push(new ReduxMiddleware(store, statePath));
// Initialize ArkhamJS
Flux.addMiddleware(middleware);
return store;
};
开发者ID:nitrogenlabs,项目名称:nl-flux,代码行数:62,代码来源:createArkhamStore.ts
示例6: setNewState
(newState: any) => setNewState(isPlainObject(initialState) ? merge(state, newState) : newState)
开发者ID:nitrogenlabs,项目名称:nl-flux,代码行数:1,代码来源:useState.ts
注:本文中的lodash/isPlainObject.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论