gpt4 book ai didi

ember.js - 如何在当前运行循环结束时运行某些东西?

转载 作者:行者123 更新时间:2023-12-04 14:47:15 25 4
gpt4 key购买 nike

我想推迟一个操作,直到所有绑定(bind)都刷新并且当前运行循环完成。我怎么做?

最佳答案

使用 Ember.run.schedule方法:

 Ember.run.schedule(queue[, context], callback[, *args]);

在这里, queue是运行循环队列(例如 'actions' )和 callback是您要执行的功能。例如:
 Ember.run.schedule('actions', function() {
console.log('I run at the end of the current runloop');
});

相关地,为防止函数多次运行,请使用 Ember.run.once (您可能还看到它被称为 scheduleOnce ):
 Ember.run.once([context,] callback[, *args]);

这将在 'actions' 中运行回调。队列。

(已更新;感谢@machty 的更正!)

关于ember.js - 如何在当前运行循环结束时运行某些东西?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14326235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com