api.imply是做什么的? [英] What does api.imply do?
问题描述
从流星文档:
此软件包的用户可以访问另一个软件包(通过传递字符串
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]
).
I have no idea what it means.
From this question I know that imply
can be employed with use
.
api.imply
的作用是什么?
api.use
和api.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")
(查看如何完成如果您想在软件包代码中使用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.export
ing Random
).
但是,meteor add
ing accounts-base
不会让整个应用程序访问其使用过的软件包(在本例中为random
).如果您的应用需要random
,则仍然需要meteor add
However, meteor add
ing 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-google
的方式api.imply
accounts-base
.
For example, see how accounts-google
is api.imply
ing 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 && meteor add markdown
,但这将需要对最终用户采取一些措施.
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屋!