码迷,mamicode.com
首页 > 数据库 > 详细

[Vue-rx] Access Events from Vue.js Templates as RxJS Streams with domStreams

时间:2018-07-17 20:16:25      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:fun   val   sid   oms   you   ret   vue   button   round   

The domStreams component property enables you to access Events from your Vue.js templates as Streams insides your subscriptions function. You can then map the Events to other values and stream them back into your Vue.js templates.

 

<template>
  <section class="section">
    <button class="button" v-stream:click="click$">Click</button>
    <h1 class="title">{{random$}}</h1>
  </section>
</template>

<script>
import { Observable } from "rxjs"

export default {
  domStreams: ["click$"],
  subscriptions() {
    const random$ = this.click$.map(() =>
      Math.random()
    )

    return {
      random$
    }
  }
}
</script>

 

[Vue-rx] Access Events from Vue.js Templates as RxJS Streams with domStreams

标签:fun   val   sid   oms   you   ret   vue   button   round   

原文地址:https://www.cnblogs.com/Answer1215/p/9325554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!