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

TypeScript mantra-core.useDeps函数代码示例

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

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



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

示例1: context

import {useDeps, composeWithTracker, composeAll, IKomposer, IKomposerData} from 'mantra-core';

export const composer: IKomposer = ({context, postId}, onData: IKomposerData) => {
  const {Meteor, Collections, Tracker} = context();

  Meteor.subscribe('posts.single', postId, () => {
    const post = Collections.Posts.findOne(postId);
    onData(null, {post});
  });

  // support latency compensation
  //  we don't need to invalidate tracker because of the
  //  data fetching from the cache.
  const postFromCache = Tracker.nonreactive(() => {
    return Collections.Posts.findOne(postId);
  });

  if (postFromCache) {
    onData(null, {post: postFromCache});
  } else {
    onData();
  }

  return null;
};

export default composeAll(
  composeWithTracker(composer),
  useDeps()
)(Post);
开发者ID:sudieartha,项目名称:Meteor-Boilerplate-Webpack-Mantra-Typescript,代码行数:30,代码来源:post.ts


示例2: onData

import { IContext } from "../configs/context";
import { useDeps, composeWithTracker, composeAll, IKomposer, IKomposerData } from "mantra-core";
import Component, { IComponentProps, IComponentActions } from "../components/logged_user_view";
import { VIEWKEY, ERRORKEY, MESSAGEKEY } from "../actions/accounts";

interface IProps {
  context?: IContext;
  showUserName?: boolean;
}

export const composer: IKomposer = ({context, showUserName}: IProps, onData: IKomposerData<IComponentProps>) => {
  const { Meteor, i18n }: IContext = context;

  onData(null, {
    userName: showUserName ? Meteor.user().profile.name : "",
    context: context
  });

  return null;
};

export const depsMapper = (context: IContext, actions: any): IComponentActions => ({
  signOut: actions.accounts.signOut
});

export default composeAll<IProps>(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(Component);
开发者ID:tomitrescak,项目名称:meteor-accountsui-semanticui-react,代码行数:29,代码来源:user_container.ts


示例3: createMutation

      },
      forceFetch: true
    }
  };
};

const mapMutationsToProps = (p: any) => ({
  removePostMutation: (id: string) => {
    return createMutation(`
      mutation removePost($id: String) {
         removePost(id: $id)
      }`, { id });
  }
});

const mapDispatchToProps = (dispatch: IDispatch, ownProps: IProps) => ({
  removePost: (mutation: any) => {
    dispatch(ownProps.removePost(ownProps.postId, mutation));
  },
});

const depsToPropsMapper = (context: IContext, actions: IActions) => ({
  removePost: actions.posts.remove
});

export default composeAll<IProps>(
  compose(apolloContainer()),
  connect({ mapQueriesToProps, mapMutationsToProps, mapDispatchToProps }),
  useDeps(depsToPropsMapper) // -> not needed here
)(Post);
开发者ID:TribeMedia,项目名称:meteor-mantra-redux-graphql,代码行数:30,代码来源:post.ts


示例4: addComment

      return {
        mutation: gql`
        mutation addComment($postId: String, $comment: String) {
           addComment(postId: $postId, comment: $comment)
        }`,
        variables: {
          postId: postId,
          comment
        }
      };
    }
  };
};

const mapStateToProps = (state: IState) => {
  return {
    error: state.post.error
  };
};

export const mapDepsToProps = (context: IContext, actions: IActions ) => ({
  create: actions.comments.create,
  clearErrors: actions.general.clearErrors,
  context: () => context
});

export default composeAll<IProps>(
  connect({mapMutationsToProps, mapStateToProps}),
  useDeps(mapDepsToProps)
)(Component);
开发者ID:TribeMedia,项目名称:meteor-mantra-redux-graphql,代码行数:30,代码来源:create_comment.ts


示例5: useDeps

import { useDeps } from 'mantra-core';
import Layout from '../components/layout';

const depsToPropsMapper = (context: IContext) => ({
  store: context.Store,
});

export const MainLayout = useDeps(depsToPropsMapper)(Layout);
export default MainLayout;
开发者ID:tomitrescak,项目名称:Marking,代码行数:9,代码来源:layout_container.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript mantra-core.IKomposerData类代码示例发布时间:2022-05-25
下一篇:
TypeScript mantra-core.composeAll函数代码示例发布时间: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