I am wondering, how could you write a program using Functional Reactive Programming that, each x timesteps, extracts a JSON object from a given URL?
I look in the Elm framework, but I am open to more general solutions. I have a method
send : Signal (Request a) -> Signal (Response String)
i.e. it receives an HTTP request wrapped in a signal and returns a response string wrapped in a signal.
Now I have a โnext stateโ function that receives input signals and creates a new game state. They are wrapped using foldp. One input is a response from an HTTP request. However, when I run it, the request is run only once, and not every timecode. How can i fix this?
EDIT: Here, how would I solve this using non-FRP (imperative style):
while True: myJson = send postRequest url --do stuff with myJSON sleep(timestep)
i.e. just request url so often, endlessly looping.
source share