I add values to an observable in a function:
var Observable = require('FuseJS/Observable');
var array = Observable('a', 'b', 'c');
// array.add('x');
function add() {
console.log("add");
array.add('z');
console.log("array: " + JSON.stringify(array));
}
module.exports = {
letters: array,
add: add
};
and try to retrieve the values in another js file:
var js1 = require('./js1');
function save() {
js1.letters.forEach(function(item) {
console.log("item: " + item);
});
}
module.exports = {
letters: js1.letters,
save: save
};
but only get the first three ones the observable was declared with:
LOG: array: {"_origin":-5,"_subscribers":[],"_isProxy":false,"_values":["a","b","c","z","z","z","z","z"],"_beganSubscriptions":false}
LOG: item: a
LOG: item: b
LOG: item: c
adding something outside of a function ( //array.add(‘x’) everything is fine
Does anybody has an idea why this effect occurs?