简体   繁体   English

Glimmer VM 中的“基于拉取的函数式反应程序”是什么意思?

[英]What does the “pull-based functional reactive program” mean in Glimmer VM?

As I saw the notion "pull-based functional reactive program"" in this article: https://engineering.linkedin.com/blog/2017/06/glimmer--blazing-fast-rendering-for-ember-js--part-2正如我在这篇文章中看到的“基于拉式的函数式反应程序”的概念: https : //engineering.linkedin.com/blog/2017/06/glimmer--blazing-fast-rendering-for-ember-js--第2部分

As I know, the "pull-based" means we have to use a regular polling way to check and update the UI according to the latest value of the states.据我所知,“基于拉取”意味着我们必须使用常规轮询方式根据状态的最新值来检查和更新 UI。 But I think there would be a lot of wasteful "polling" and may even cause the inefficiency of the app running if the app has a lot of states and they are actually not frequently changed most of the time.但是我认为如果应用程序有很多状态并且实际上大多数时间不经常更改,则会有很多浪费的“轮询”,甚至可能导致应用程序运行效率低下。

So, I think there should be something I missed here, how can I understand that?所以,我认为这里应该有一些我错过的东西,我怎么能理解呢?

While a VM architecture is a novel way of modeling rendering, the initial execution of the VM sets up Reference and Revision Tag subsystems, which allow us to model a pull-based functional reactive program (FRP) used for updating the UI.虽然 VM 架构是一种新颖的渲染建模方式,但 VM 的初始执行会设置参考和修订标记子系统,这使我们能够对用于更新 UI 的基于拉式的功能反应程序 (FRP) 进行建模。 What this means in practice is that there is no notion of observers or subscriptions to keep values updated in the UI, but rather that we allow the backing values in a template to freely mutate.这在实践中意味着没有观察者或订阅的概念来保​​持 UI 中的值更新,而是我们允许模板中的支持值自由变化。 For now, the simplest way to conceptualize this system is something like the following:目前,概念化这个系统的最简单方法如下:

I'd highly recommend Chris Garrett's set of blog posts on this .我强烈推荐 Chris Garrett在这方面的一组博客文章 He does a much more comprehensive job of explaining this, but push vs pull reactivity isn't about polling at intervals for a change it is much more akin to imperative vs declarative programming.他对此做了更全面的解释,但推与拉反应性并不是每隔一段时间轮询一次更改,它更类似于命令式与声明式编程。 It places the onus for reacting to changes in state onto the consumer (pull) as opposed to placing the responsiblity of notifying the app about state changes onto the changer (push).它将对状态变化做出反应的责任放在消费者身上(拉),而不是将通知应用状态变化的责任放在改变者身上(推送)。

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

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