You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this could reasonably be done with an additional value in the rule set which looks like :stateful? true or similar. For example:
{:id::my-flow:rules [...]
:stateful?true}
The reasoning for this is allowing truly declarative rule sets, where the order does not matter, cycles may occur, and rules may be skipped. This is essential for representing anything like a game loop or anything more complex than "first this, then this, then this."
With lots of respect, I simply have no need for state tracking, so I ripped out what re-frame-async-flow-fx was doing with it and kept only the part which applies in my code: binding rules that say "when this happens, do this," rather than "first this, then this."
Login example
To outline a real-world example of how this is used, here's a high-level view of my login flow.
Try to load credentials from cache
If no credentials were found, show the login screen
Once the credentials were found or the login screen was navigated, talk to the server
If the credentials were loaded properly, but they're invalid (expired or malicious), the server will then give us an error, which shows the login screen. At which point, the rules should loop back so that, when the user logs in, rule number 3 is triggered and the process starts over.
Concurrent example
Given :first-dispatch-n, as described in ticket #14, these declarative rules can handle multiple flows concurrently. You first dispatch 5 events, say, and then, as each finishes, the flow is orchestrated by the declarative rules.
The text was updated successfully, but these errors were encountered:
jeaye
changed the title
Please allow for non-stateful rule sets
Please allow for stateless rule sets
Jan 13, 2018
I think this could reasonably be done with an additional value in the rule set which looks like
:stateful? true
or similar. For example:The reasoning for this is allowing truly declarative rule sets, where the order does not matter, cycles may occur, and rules may be skipped. This is essential for representing anything like a game loop or anything more complex than "first this, then this, then this."
I have a working version of the declarative-only rules here: https://github.com/jeaye/re-frame-rules/blob/36811b3dfc3f56079209ed0f9341cb99fa79fa36/src/com/jeaye/re_frame_rules.cljs#L111
With lots of respect, I simply have no need for state tracking, so I ripped out what re-frame-async-flow-fx was doing with it and kept only the part which applies in my code: binding rules that say "when this happens, do this," rather than "first this, then this."
Login example
To outline a real-world example of how this is used, here's a high-level view of my login flow.
If the credentials were loaded properly, but they're invalid (expired or malicious), the server will then give us an error, which shows the login screen. At which point, the rules should loop back so that, when the user logs in, rule number 3 is triggered and the process starts over.
Concurrent example
Given
:first-dispatch-n
, as described in ticket #14, these declarative rules can handle multiple flows concurrently. You first dispatch 5 events, say, and then, as each finishes, the flow is orchestrated by the declarative rules.The text was updated successfully, but these errors were encountered: