在github上fromArray的Rx维基
coffee> rext = require 'rx'
coffee> arr = [1..5]
[ 1, 2, 3, 4, 5 ]
coffee> obs = rext.Observable.fromArray(arr)
{ _subscribe: [Function] }
coffee> obs.subscribe( (x) -> console.log("added value: " + x))
added value: 1
added value: 2
added value: 3
added value: 4
added value: 5
{ isStopped: true,
observer:
{ isStopped: true,
_onNext: [Function],
_onError: [Function: defaultError],
_onCompleted: [Function: noop] },
m: { isDisposed: true, current: null } }
coffee> arr.push(12) # expecting "added value: 12"
6 # instead got new length of array
coffee>
这真的看起来像subscribe
功能才会触发一次,在创建时。 看起来这是一个有点用词不当,因为我真的只是换eaching的阵列,而不是观察它的变化。 这代码几乎是完全一样的维基,虽然什么。 因此,无论我做错了或subscribe
不工作我如何期望。