api.imply 有什么作用? [英] What does api.imply do?

查看:13
本文介绍了api.imply 有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自 Meteor 文档:

授予此包的用户访问另一个包的权限(通过传入字符串 packagename)或包的集合(通过传入字符串数组 [packagename1, packagename2]).

Give users of this package access to another package (by passing in the string packagename) or a collection of packages (by passing in an array of strings [packagename1, packagename2]).

我不知道这是什么意思.
来自 这个问题 我知道 imply 可以与 use 一起使用.

I have no idea what it means.
From this question I know that imply can be employed with use.

api.imply 有什么作用?
api.useapi.imply 到底有什么区别?

What does api.imply do?
What's exactly the difference between api.use and api.imply?

推荐答案

api.use 允许一个包访问其他包导出的符号.

api.use gives a package access to other packages exported symbols.

例如你需要api.use("random") (看看它是如何在accounts-base 包中完成的),如果你想在包代码中使用Random 符号(看看random package.js 是如何api.exporting Random).

For example you need to api.use("random") (see how it's done in the accounts-base package) if you want to use the Random symbol in a package code (see how the random package.js is api.exporting Random).

但是,meteor adding accounts-base 不会让您的整个应用程序访问其使用的包(在这种情况下为 random).如果您的应用需要random,您仍然需要meteor add.

However, meteor adding accounts-base wouldn't give your whole application access to its used packages (random in this case). If your app needs random, you'd still need to meteor add it.

api.imply 另一方面,允许整个应用程序访问该包导出的符号.

api.imply on the other hand, gives the whole application access to that package exported symbols.

例如,看看如何accounts-googleapi.implying accounts-base.

For example, see how accounts-google is api.implying accounts-base.

accounts-base 负责导出Accounts符号,当你meteor add accounts-google时,不仅accounts-base也会添加到你的应用中依赖项,但 accounts-base 符号也在您的应用中可用,特别是因为它是隐含的.

accounts-base is responsible for exporting the Accounts symbol, when you meteor add accounts-google, not only does accounts-base is also added in your application dependencies, but accounts-base symbols are also made available in your app, specifically because it was implied.

accounts-base 在其自己的代码 (api.use) 中使用 Accounts 并将其依赖项符号导出到整个应用程序 (api.imply).

accounts-base is both using Accounts in its own code (api.use) and exporting its dependencies symbols to the whole app (api.imply).

api.imply 可用于制作只是拉入其他一些包的影子包".

api.imply can be used to make "shadow packages" that are just pulling in some other packages.

例如,在某些时候,MDG 将 showdown 包重命名为 markdown,他们可以声明 meteor remove showdown &&流星添加降价,但它需要对最终用户进行一些操作.

For example, at some point MDG renamed the showdown package to markdown, they could just have stated to meteor remove showdown && meteor add markdown, but it would have required some actions on end users.

他们所做的是保留 showdown 包,而只是 让它暗示新的markdown.

What they did instead is keeping the showdown package and just make it implying the new markdown package.

这篇关于api.imply 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆