Functional reactive programming implementations seem to have the observer as being passively dependent upon streams providing them with values.
Is it possible to request a new value from down stream?
For example, if I have a stream that serves co-ordinates of the apple in the game Snake, if the apple has been eaten then how can I ask for a new value?
The source stream doesn't know that a new apple is required.
This has an interesting implementation that uses recursion.
function apple() {
var applePos = randomPos()
return
position
.filter(p => p.equals(applePos))
.take(1)
.flatMapLatest(apple)
.toProperty(applePos)
}
Is there a more straight forward way of doing this?
Perhaps I could have a stream that knows when a value has been taken and immediately generates a new one and holds it in a buffer.