Any(filter) return undefined


#1

I do like this ( in fuse document)
When I

console.log(hasBoats.value); => undefined
console.log(hasAircraft.value); => undefined
console.log(hasCar.value); => undefined

var vehicles = Observable(
    {type: "car", name: "SuperSpeeder 2000"},
    {type: "car", name: "Initial Dash 2k00"},
    {type: "boat", name: "Floaty McFloatface"}
);
var hasBoats = vehicles.any({type: "boat"}); 
var hasAircraft = vehicles.any({type: "aircraft"}); 
var hasCar = veichles.any(function(x) { return x.type === "car"; })

#2

Hey @hindux, its because its a reactive operator.

Checkout @Uldis’s explanation here: How to get, using Javascript, the value of a parameter passed to a page?

I just made a full working example, try it out and see how things work:

<App>
	<JavaScript>
	var Observable = require('FuseJS/Observable');
	
	var vehicles = Observable(
		{type: "car", name: "SuperSpeeder 2000"},
		{type: "car", name: "Initial Dash 2k00"},
		{type: "boat", name: "Floaty McFloatface"}
	);

	var hasBoats = vehicles.any({type: "boat"}); //true
	var hasAircraft = vehicles.any({type: "aircraft"}); //false
	var hasCar = vehicles.any(function(x) { return x.type === "car"; }); //true
	
	hasBoats.onValueChanged(module, function(x) {
		console.log("hasBoats: " + x);
	});

	hasAircraft.onValueChanged(module, function(x) {
		console.log("hasAircraft: " + x);
	});

	hasCar.onValueChanged(module, function(x) {
		console.log("hasCar: " + x);
	});

	module.exports = {
		hasBoats: hasBoats,
		hasAircraft: hasAircraft,
		hasCar: hasCar,
	};
	</JavaScript>
	
	<StackPanel>
		<Text Value="hasBoats: {hasBoats}" />
		<Text Value="hasAircraft: {hasAircraft}" />
		<Text Value="hasCar: {hasCar}" />
	</StackPanel>
</App>