當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。