futurescript
futurescript copied to clipboard
Better stream support via alias?
For FRP, look at various frp solutions
I suggest using a pipe equivalent +> for working with streams (piping). +> Could perhaps just be an alias for . but be used to make it more clear we are operating on a stream (or whatever other special construct we like to clearly differentiate from "normal" function call)
const source = getAsyncStockData();
const subscription = source
.filter(quote => quote.price > 30)
.map(quote => quote.price)
.subscribe(
price => console.log(`Prices higher than $30: ${price}`),
err => console.log(`Something went wrong: ${err.message}`)
);
/* When we're done */
subscription.dispose();
Could become
source: getAsyncStockData()
subscription: source
+>filter quote -> quote.price > 30
+>map quote -> quote.price
+>subscribe
price -> console.log `Prices higher than $30: \price",
err -> console.log "Something went wrong: \err.message
# When we're done
subscription.dispose()