javascript - bacon.js Bus.plug: Uncaught Error: not an Observable : [object Object] -
i trying baconjs's tutorial. https://baconjs.github.io/tutorials.html#content/tutorials/2_ajax
but, got error @ "bus.plug"
var cart = shoppingcaret([]) var cartview = shoppingcartview(cart.contentsproperty) var newitemview = newitemview() cart.addbus.plug(newitemview.newitemstream)
error:
uncaught error: not observable : [object object] shopbundle.js:145 assertobservable shopbundle.js:2650 bus.plug
i use follows
- baconjs@0.7.53
- jquery@2.1.3
- bacon-jquery-bindings@0.2.8
- webpack 1.7.3
what doing wrong? thanks.
edit: 2015/3/25
cause newitemview.newitemstream not observable.
(newitemview.newitemstream instanceof bacon.observable
returns false.)
and newitemview.newitemstream eventstream
eventstream {takeuntil: function, sampledby: function, combine: function, flatmaplatest: function, fold: function…}
isn't eventstream observable?
i have made newitemstream follows:
var $button = $('#addbutton'); var $namefield = $('#nametext'); var newitemproperty = bacon.$.textfieldvalue($namefield); var newitemclick = $button.aseventstream('click'); var newitemstream = newitemproperty.sampledby(newitemclick);
following work fine. miss when first time question.
/* and, try more simple code. has same error. */
var somestream = bacon.interval(1000).map(function() { return new date().gettime(); }); var bus = new bacon.bus(); bus.log(); bus.plug(somestream);
it caused "bacon-jquery-bindings"(https://www.npmjs.com/package/bacon-jquery-bindings)
var bacon = require('baconjs'); var $ = jquery = require("jquery"); bacon.$ = require("bacon-jquery-bindings"); <-
it seems overwrite aseventstream function.
we should use "bacon.jquery"(https://www.npmjs.com/package/bacon.jquery)
Comments
Post a Comment