odoyle-rules icon indicating copy to clipboard operation
odoyle-rules copied to clipboard

Clarification on o/reset! usage.

Open drewverlee opened this issue 3 years ago • 1 comments

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.

drewverlee avatar Jun 02 '22 01:06 drewverlee

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.

oakes avatar Jun 02 '22 06:06 oakes