Fork me on GitHub

Hi, is there any way to set an observable to a clara session to get any new insertion/rectraction fo facts? (I am wondering if it would be possible to use a clara session as a source of a stream of facts).


@nlessa Clara only returns new sessions in response to external calls to insert, retract, fire-rules etc. so if you’re looking to listen for changes in response to those actions I’d suggest just querying the session after those calls. It is also possible to add arbitrary listeners to a session - you can see the protocol at and an example that simply records all operations listened upon at - but keep in mind that listeners often take you into internal implementation details that could change. Also Clara sessions are immutable, in keeping with typical Clojure data structure semantics. Inserting/retracting facts and firing rules returns a new session with the relevant operation applied but leaves the original unchanged. It might be possible to give a better answer if we had a better idea what you’re trying to accomplish.