I want to extend IInspect of ankha so that it uses a defrecord, but it's not
working properly. When the map containing the defrecord instance is passed
through om/root, and to the inspector, it doesn't display properly (it prints
like a normal map). When a map with the defrecord instance is directly passed
to anhka's inspector, it works.
Here is the code:
(ns testapp.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[ankha.core :as ankha]
[goog.dom :as gdom]
[sablono.core :as html :refer-macros [html]]))
(defrecord RecordTest [x y])
(extend-protocol ankha/IInspect
RecordTest
(-inspect [this]
(html [:div
[:button {:class "btn"} "Stuff"]])))
(defn data-view [data owner]
"Used for displaying an ankha inspector view for the state. It is a simple
way to view data."
(reify
om/IRender
(render [this]
(html
[:div
(om/build ankha/inspector data)
(om/build ankha/inspector {:test (RecordTest. 1 2)})]))))
(om/root
data-view
{:x 5 :test (RecordTest. 1 2)}
{:target (gdom/getElement "app")})
Here is my project.clj file:
(defproject testapp "0.1.0-SNAPSHOT"
:description "FIXinME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2277"]
[om "0.7.1"]
[ankha "0.1.3"]
[sablono "0.2.21"]]
:profiles {:dev {:repl-options {:timeout 120000}
:plugins [[lein-cljsbuild "1.0.3"]]}}
:source-paths ["src"]
:cljsbuild {:builds {:dev
{:source-paths ["src"]
:compiler {:output-to "out/dev/dev-main.js"
:output-dir "out/dev"
:optimizations :none
:pretty-print true
:preamble ["react/react.min.js"]
:source-map "out/dev-main.js.map"}}}})
If you do a (.log js/console (:test data)) in the data-view before render, it
prints the fact that it is a MapCursor. I don't know if this interfers with
the extend-protocol, or what.
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.