oakes / odoyle-rules

A rules engine for Clojure(Script)
The Unlicense
530 stars 20 forks source link

Clarification on o/reset! usage. #15

Open drewverlee opened 2 years ago

drewverlee commented 2 years ago

The docs seem to suggest you can use reset! outside the rules block.

The session dynamic var will have the current value of the session, and reset! will update it so it has the newly-inserted value. This is nice if you want to thread a lot of calls together, or if you want to write code that works the same both inside and outside of the rule.

Which seems to disagree with the helpful exception:

You may only call `reset!` in a :then or :then-finally block

Can you give an example of something that runs inside and outside the rule code block.

oakes commented 2 years ago

It can only be called inside of a rule. What i meant is that the threaded insert calls you make can run outside of a rule too, so you could put them in a function and run them in either place. If you use insert! instead, those calls will not work outside of a rule.