当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript recompose.compose函数代码示例

本文整理汇总了TypeScript中recompose.compose函数的典型用法代码示例。如果您正苦于以下问题:TypeScript compose函数的具体用法?TypeScript compose怎么用?TypeScript compose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了compose函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: compose

export const callDevice = () =>
  compose(
    connect(
      undefined,
      (dispatch): InjectedDispatch => ({
        __injectedDispatch: dispatch,
      }),
    ),
    graphql<
      CallDeviceInjectedProps & InjectedDispatch,
      {},
      {deviceId: string; interfaceId: string; method: string},
      Partial<CallDeviceInjectedProps>
    >(
      gql`
        mutation($deviceId: String!, $interfaceId: String!, $method: String!) {
          callDevice(
            deviceId: $deviceId
            interfaceId: $interfaceId
            method: $method
          ) {
            id
          }
        }
      `,
      {
        props: ({
          mutate,
          ownProps: {__injectedDispatch: dispatch},
        }): CallDeviceInjectedProps => ({
          callDevice(call: Call) {
            return mutate!({
              variables: call,
            }).catch(() => {
              dispatch(
                action(actions.showSnackbar, {
                  label: 'Failed to call device',
                  type: 'warning' as 'warning',
                }),
              )
            })
          },
        }),
      },
    ),
  )
开发者ID:Pajn,项目名称:RAXA,代码行数:46,代码来源:mutations.ts

示例2: withState

/*
 * 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 { compose, withState } from 'recompose';
import { AdvancedFilter as Component, Props as ComponentProps } from './advanced_filter';

export interface Props {
  /** Optional value for the component */
  value?: string;
  /** Function to invoke when the filter value is committed */
  commit: (value: string) => void;
}

export const AdvancedFilter = compose<ComponentProps, Props>(
  withState('value', 'onChange', ({ value }) => value || '')
)(Component);
开发者ID:elastic,项目名称:kibana,代码行数:19,代码来源:index.ts

示例3: compose

 */

export default compose(
  connect(
    undefined,
    { getAllLinodeConfigs }
  ),
  lifecycle<
    OutterProps & { getAllLinodeConfigs: GetAllLinodeConfigsRequest },
    {}
  >({
    componentDidMount() {
      // tslint:disable-next-line:no-shadowed-variable
      const { linodeId, getAllLinodeConfigs } = this.props;
      getAllLinodeConfigs({ linodeId });
    },

    componentDidUpdate(prevProps) {
      // tslint:disable-next-line:no-shadowed-variable
      const { linodeId: prevLinodeId, getAllLinodeConfigs } = this.props;
      const { linodeId } = prevProps;

      if (linodeId === prevLinodeId) {
        return;
      }

      getAllLinodeConfigs({ linodeId });
    }
  })
);
开发者ID:linode,项目名称:manager,代码行数:30,代码来源:initLinodeConfigs.ts

示例4: connect

import { getLinode as _getLinode } from 'src/store/linodes/linode.requests';
import { GetLinodeRequest } from 'src/store/linodes/linodes.actions';

interface OuterProps {
  linodeId: number;
}

/**
 * Get the Linode on mount and on linodeId change.
 */

export default compose<OuterProps, {}>(
  connect(
    undefined,
    { getLinode: _getLinode }
  ),
  lifecycle<OuterProps & { getLinode: GetLinodeRequest }, void>({
    componentDidMount() {
      const { linodeId, getLinode } = this.props;
      getLinode({ linodeId });
    },
    componentDidUpdate(prevProps) {
      const { linodeId: prevLinodeId } = prevProps;
      const { linodeId } = this.props;
      if (linodeId !== prevLinodeId) {
        _getLinode({ linodeId });
      }
    }
  })
);
开发者ID:linode,项目名称:manager,代码行数:30,代码来源:initLinode.ts

示例5: withState

import Player from "common/player/Player"
import { MeasureList } from "common/measure"

interface Inner {
  player: Player
  measureList: MeasureList
}

interface Outer extends Inner {
  playerPosition: number
}

interface Props extends Outer {
  onTick: (number) => void
}

export default compose<Inner, Outer>(
  withState("mbtTime", "updateMBTTime", 0),
  withHandlers<Inner & { updateMBTTime: (number) => void }, {}>({
    onTick: props => tick => props.updateMBTTime(props.measureList.getMBTString(tick, props.player.timebase)),
  }),
  lifecycle<Props, {}>({
    componentDidMount() {
      this.props.player.on("change-position", this.props.onTick)
    },
    componentWillUnmount() {
      this.props.player.on("change-position", this.props.onTick)
    }
  })
)
开发者ID:ryohey,项目名称:signal,代码行数:30,代码来源:withMBTTime.ts


注:本文中的recompose.compose函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。