简体   繁体   English

确保流星脚本先执行(在客户端上)

[英]Meteor script ensured to be executed before everything else (on Client)

I guess the topic of Meteor forcing execution order heuristics on its users instead of providing import semantics has been discussed to death already. 我想关于流星强迫用户执行执行顺序启发式而不是提供import语义的话题已经讨论到死了。

Nevertheless, I think there should at the very least be a way to make 100% sure that a certain set of scripts can be run before everything else. 但是,我认为至少应该有一种方法可以100%确保可以在其他所有操作之前运行特定的脚本集。 From what I understand, since the load order heuristic goes depth-first over everything else (even if you have multiple lib folders in different places, the ones at a greater depth are run first for some reason), there is basically no way to ensure that some scripts are executed before everything else, no matter how deep it goes, unless you put it in a package. 据我了解,由于加载顺序试探法在所有其他问题上都排在首位(即使您在不同位置有多个lib文件夹,出于某种原因也要先运行更深的lib文件夹),所以基本上没有办法确保除非您将其放入软件包中,否则无论脚本有多深入,都必须先执行某些脚本。

Is that correct? 那是对的吗? And is there anything to be expected to remedy the situation in an upcoming release? 在即将发布的版本中,有什么期望可以纠正这种情况吗?

For now, I am considering writing a little load-order-util package that at the very least allows deferring execution of a callback until startup and after a given set of globally defined symbols are ready, like so: 现在,我正在考虑编写一个小的load-order-util程序包,该程序包至少允许将回调的执行推迟到startup之前以及在给定的一组全局定义的符号准备好之后,如下所示:

Global.dependsOnSymbols = function(symbolNameOrNames, cb) { ... };

Any better suggestions? 还有更好的建议吗?

As you can realize by reading: 正如您可以通过阅读了解到的:

How do I change the order in which Meteor loads Javascript files? 如何更改Meteor加载Javascript文件的顺序?

and

In Meteor JS, how to control Javascript load order in relation to DOM load order? 在Meteor JS中,如何控制与DOM加载顺序相关的Javascript加载顺序? For animations 对于动画

as things are right now, it is probably better to stick with the loading conventions offered by the framework itself. 按照目前的情况,最好还是使用框架本身提供的加载约定。

Anyway, the upcoming 1.3 release should finally address the problem providing ES2015 modules support. 无论如何, 即将发布的1.3版本最终应该解决提供ES2015模块支持的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM