Reactor
Reactor copied to clipboard
Let Commands wait for state to execute or expire
The intent is to make it easy to issue several back-to-back commands that implicitly depend on each other before they can run. GetLocation and GetWeather are an example. You need to know the location before you can request the weather. By issuing them both at the same time, your location command can see that the existing location is recent enough, and choose to do nothing in it's execute(state:, core:) function, and the weather command will still run properly since it will find location in the proper place in state.
- Existing commands will be unaffected. Defaults always assume commands will run.
- Any command that implements
canExecute(state:)will default to expiring in 10 seconds. - Commands may never run if you stop sending events to
core, but if that happens your app is lifeless, so in practice this shouldn't be a problem...I think.