Ilia Choly
Ilia Choly

Reputation: 18557

passing data to noir views - Clojure

I'm working with Noir and I can't figure out how to pass information to the views. Right now I have a ref in proj.core/my-ref which is updated in a worker thread. I need to access the ref's value from a view created via defpage located at proj.views.my-view.

What would be the idiomatic way of sharing this ref? I was thinking of passing it in a closure somehow but I don't see how that would work with the way noir pulls in the views

ie

(noir.server/load-views-ns 'proj.views)

Upvotes: 4

Views: 146

Answers (1)

DanLebrero
DanLebrero

Reputation: 8593

Move the ref to it's own namespace and then just require proj.core in your proj.views, like:

(ns proj.views
 (:require proj.model))

(defpage "/foo" [] (@proj.model/my-ref)

Upvotes: 2

Related Questions