Open hamid512 opened 4 years ago
how i prevent sending empty string '' if number is odd, like prevent .to from running and just move to next stream data? if defeats the purpose of multiple branching topics for me my code
`const checkforOdd = (kafkaMessage) => { const value = kafkaMessage.value.toString("utf8"); // console.log(value) if(!(parseInt(value) % 2 == 0)){ return value }else{ return '' }
}; const checkforEven = (kafkaMessage) => { const value = kafkaMessage.value.toString("utf8"); if(parseInt(value) % 2 == 0){
return value } else{ return '' }
};
const kafkaStreams = new KafkaStreams(config);
kafkaStreams.on("error", (error) => { console.log("Error occured:", error.message); });
const stream = kafkaStreams.getKStream('test-topic'); const [one$, two$] = stream .branch([() => true, () => true]);
const producerPromiseOne = one$ .map(checkforOdd) .to("odd");
const producerPromiseTwo = two$ .map(checkforEven) .to("even");`
@rsilvestre @elmarx @crcastle @drublic
how i prevent sending empty string '' if number is odd, like prevent .to from running and just move to next stream data? if defeats the purpose of multiple branching topics for me my code
`const checkforOdd = (kafkaMessage) => { const value = kafkaMessage.value.toString("utf8"); // console.log(value) if(!(parseInt(value) % 2 == 0)){ return value }else{ return '' }
}; const checkforEven = (kafkaMessage) => { const value = kafkaMessage.value.toString("utf8"); if(parseInt(value) % 2 == 0){
};
const kafkaStreams = new KafkaStreams(config);
kafkaStreams.on("error", (error) => { console.log("Error occured:", error.message); });
const stream = kafkaStreams.getKStream('test-topic'); const [one$, two$] = stream .branch([() => true, () => true]);
const producerPromiseOne = one$ .map(checkforOdd) .to("odd");
const producerPromiseTwo = two$ .map(checkforEven) .to("even");`