• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript recompose.compose函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript recompose.pure函数代码示例发布时间:2022-05-25
下一篇:
TypeScript recast.visit函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap