2013-10-02 34 views
2

我有當輸入事件流presssedBacon.js如何根據另一個屬性過濾事件流?

var enter = 
    $('#text') 
    .asEventStream('keydown') 
    .filter(function(e){ 
    return e.keyCode === 13 
    }) 

這個偉大的工程。但是,如果按下ENTER並且另一個屬性textMatches爲真,我只想採取行動。我該怎麼做呢?我試過

var advance = textMatches.and(enter) 

但它沒有奏效。

回答

3

爲兩個屬性之間的操作定義布爾方法,但enter是一個EventStream。屬性可用於過濾EventStreams,以下內容適用於您的用例:

var advance = enter.filter(textMatches) 
相關問題