1

Im from C#, and my clojure expirience is about two weeks. I want track some object and receive notifications from it. In C# im using events. Any clojure best practices for this problem?

For example:

service-controller.clj

(def shared-state)
(defn start-watch [x]
 ;; add object to watch in shared state
    )

(loop blah blah
 ;; check all objects in shared state and in some cases delete object, change object
 recur  )

in another file, i want to add listeners for service-controller shared state. engine.clj (add-listener service-controller/shared-state fn blah)

(service-controller/start-watch x)

I found agent and add-watch, its ok, but how i can modify vector inside agent?

1 Answer 1

1

send and send-off are used to alter agent state. The documentation has more details, but basically you call send with a function that computes the new state.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.