Closed ertugrulcetin closed 11 months ago
@oakes any ideas?
There is no support for removing rules right now. I think it would be fairly straight-forward to implement, but what is your use case? Are you adding/removing rules dynamically?
I would use this to write a react hook that subscribes to an odoyle session, so o/add-rule
on mount and then remove the rule on unmount.
@oakes when I'm writing or updating rules in my ClojureScript project, Shadow-cljs hot-loads the rules with each file change. Thus, I need to remove rules before each hot load. Additionally, I can manipulate them while working in my REPL. So, it's crucial for my use case. Also yes, I'm adding/removing rules dynamically
@nivekuil @ertugrulcetin Can you please try the latest commit? I added remove-rule
which works like this:
(o/remove-rule session ::my-rule-name)
If you're using deps.edn you can bring the commit in like this:
net.sekao/odoyle-rules {:git/url "https://github.com/oakes/odoyle-rules.git"
:git/sha "800aba8053a1643184ca395a6712d1e1d34e973a"}
@oakes, thank you so much for the update! It seems to be working for me. I initially thought it would be harder to remove given the presence of defrecords and the complex logic during node construction. I assumed it would require more steps to remove a rule, similar to maintaining balance in a tree
I thought it'd be harder too :P It would've been if there was any node-sharing going on, but I never implemented that because I thought it would complicate the codebase.
Cool, thanks again! I think you can push the new release to clojars
On second thought, I think there is a bit more I need to do to properly remove the rule. I will look into this today.
@oakes okay thanks a lot! Also could you check this new issue once you have time? It is very important IMHO: https://github.com/oakes/odoyle-rules/issues/27
Yep sure I'll take a look later today.
This feature is now in version 1.3.0, so I'll close this.
@oakes Thank you for the update, I appreciate it!
I'd like to remove a rule dynamically, is it possible in current API, if not do you have quick code snippet?