<i id='v95tC'><tr id='v95tC'><dt id='v95tC'><q id='v95tC'><span id='v95tC'><b id='v95tC'><form id='v95tC'><ins id='v95tC'></ins><ul id='v95tC'></ul><sub id='v95tC'></sub></form><legend id='v95tC'></legend><bdo id='v95tC'><pre id='v95tC'><center id='v95tC'></center></pre></bdo></b><th id='v95tC'></th></span></q></dt></tr></i><div id='v95tC'><tfoot id='v95tC'></tfoot><dl id='v95tC'><fieldset id='v95tC'></fieldset></dl></div>

  • <tfoot id='v95tC'></tfoot>

    <small id='v95tC'></small><noframes id='v95tC'>

    1. <legend id='v95tC'><style id='v95tC'><dir id='v95tC'><q id='v95tC'></q></dir></style></legend>
      • <bdo id='v95tC'></bdo><ul id='v95tC'></ul>

        函数响应式编程相对于事件监听器的优势

        时间:2023-09-04
        1. <i id='XUZTF'><tr id='XUZTF'><dt id='XUZTF'><q id='XUZTF'><span id='XUZTF'><b id='XUZTF'><form id='XUZTF'><ins id='XUZTF'></ins><ul id='XUZTF'></ul><sub id='XUZTF'></sub></form><legend id='XUZTF'></legend><bdo id='XUZTF'><pre id='XUZTF'><center id='XUZTF'></center></pre></bdo></b><th id='XUZTF'></th></span></q></dt></tr></i><div id='XUZTF'><tfoot id='XUZTF'></tfoot><dl id='XUZTF'><fieldset id='XUZTF'></fieldset></dl></div>

            <small id='XUZTF'></small><noframes id='XUZTF'>

              <legend id='XUZTF'><style id='XUZTF'><dir id='XUZTF'><q id='XUZTF'></q></dir></style></legend>

              <tfoot id='XUZTF'></tfoot>
                <tbody id='XUZTF'></tbody>

                <bdo id='XUZTF'></bdo><ul id='XUZTF'></ul>
                • 本文介绍了函数响应式编程相对于事件监听器的优势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我听说过很多关于函数式反应式编程的内容,并决定看看有什么大不了的.通过 bacon.js 文档,似乎主要区别在于,我没有在组件上设置事件侦听器,而是在其上创建事件流,并将事件处理程序传递到流中.换句话说,我真正做的只是将事件处理程序从组件移动到事件流.是这样吗?如果是这样,这样做的最大优势是什么?

                  I've been hearing a lot about functional reactive programming, and decided to check out what the big deal is. Going through the bacon.js documentation, it seems that the main difference is that instead of setting an event listener on a component, I create an event stream on it, and pass the event handler into the stream instead. In other words, all I really did was move the event handler from the component to the event stream. Is that it? If so, what's the big advantage of doing this?

                  推荐答案

                  是吗?

                  没有.这是关于拥有事件流.最后你仍然会为它们附加监听器来执行效果,但是在源和目标之间你有一个非常强大的抽象.

                  No. It's about having event streams. You still will attach listener to them in the end to execute effects, but between the source and the destination you've got a very mighty abstraction.

                  这样做有什么好处?

                  事件流确实有很多 高阶函数来轻松处理它们,并在不写出所有容易出错的样板代码的情况下编写它们.

                  The event streams do have lots of higher-order functions to easily deal with them, and for composing them without writing out all the error-prone boilerplate code.

                  正如文档所说的非常好,培根

                  通过从命令式切换到函数式,将您的活动意大利面变成干净声明式风水培根.这就像用 mapfilter 等函数式编程概念替换嵌套的 for 循环.停止处理单个事件并改为使用事件流.将您的数据与 mergecombine 相结合 [并使用] 更重的武器 [例如] flatMapcombineTemplate..p>

                  turns your event spaghetti into clean and declarative feng shui bacon, by switching from imperative to functional. It's like replacing nested for-loops with functional programming concepts like map and filter. Stop working on individual events and work with event streams instead. Combine your data with merge and combine [and wield] heavier weapons [like] flatMap and combineTemplate.

                  这篇关于函数响应式编程相对于事件监听器的优势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如果有的话,为什么 addEventListener 在事件之前触 下一篇:鼠标悬停圆圈 HTML5 画布

                  相关文章

                  最新文章

                  • <bdo id='Y5aJE'></bdo><ul id='Y5aJE'></ul>

                  <i id='Y5aJE'><tr id='Y5aJE'><dt id='Y5aJE'><q id='Y5aJE'><span id='Y5aJE'><b id='Y5aJE'><form id='Y5aJE'><ins id='Y5aJE'></ins><ul id='Y5aJE'></ul><sub id='Y5aJE'></sub></form><legend id='Y5aJE'></legend><bdo id='Y5aJE'><pre id='Y5aJE'><center id='Y5aJE'></center></pre></bdo></b><th id='Y5aJE'></th></span></q></dt></tr></i><div id='Y5aJE'><tfoot id='Y5aJE'></tfoot><dl id='Y5aJE'><fieldset id='Y5aJE'></fieldset></dl></div>
                  <legend id='Y5aJE'><style id='Y5aJE'><dir id='Y5aJE'><q id='Y5aJE'></q></dir></style></legend>

                  <small id='Y5aJE'></small><noframes id='Y5aJE'>

                      <tfoot id='Y5aJE'></tfoot>