我試圖做一個非常基本的基座應用程序來顯示項目列表,或者如果列表是空的文本消息。底座:您可以使用什麼數據流來呈現新初始化的空列表?
我以爲我想要的是:
- 一個數據模型,其中[:根:項目]將是我的產品清單
- 模板功能的頁面([:根])
- 爲空列表靜態模板函數
- 與元素
- 在應用程序的啓動列表的動態模板功能,發送一條消息,將初始化列表爲空
- 在渲染中,迴應:
[node-create [] :map]
通過做...什麼都沒有?[node-create [:root] :map]
通過添加的模板空列表
要清楚,我想到底會顯示什麼渲染整個頁面
[node-create [:root :items] :map]
模板(無元素) <html>
<div>My list</div>
<p>There is nothing in the list</p>
</html>
,當有東西在列表中:
<html>
<div>My list</div>
<ul>
<li>item1</li>
<li>item2</li>
</ul>
</html>
我在正確的軌道上嗎?
我被困在初始化數據模型是我想要的。我得到的最接近是這樣的:
;; behavior.clj
(defn init-root-transform [old-value message]
{})
(defn init-items-transform [old-value message]
[])
(def example-app
{:version 2
;; :transform [[:set-value [:greeting] set-value-transform]]})
:transform [[:bootstrap [:root] init-app-transform]
[:bootstrap-systems [:root :items] init-items-transform]
]})
;; start.cljs
... skipped...
(app/begin app)
(p/put-message (:input app) {msg/type :bootstrap msg/topic [:root]})
(p/put-message (:input app) {msg/type :bootstrap-systems msg/topic [:root :items]})
的問題是,這樣一來,我得到一個數據模型與單:包含值根節點{:項目[]}。
這可能聽起來像一個非常愚蠢的問題,但這兩個數據模型是一樣的嗎?
[:root :systems] => []
[:root] => {:systems []}
當我啓動我的應用程序,生成的渲染三角洲是:
[node-create [] :map]
[node-create [:root] :map]
[value [:root] nil {:items [] }]
我不認爲這是適合我的渲染項目的清單,是嗎?
UPDATE:
@solussd意味着:兩個datamodels是相同的;但是,當生成以下三角洲時:
[value [:root] nil {:items []}]
我仍然無法處理它。如果我加渲染的配置是這樣的:
[value [:root :items] render-items-list]
然後render-items-list
功能不調用。
如果我加渲染的配置是這樣的:
[value [:root] render-root]
然後render-root
函數將被調用,但很明顯,不正確的「路徑」,我想這也將被調用時,其他任何更改爲數據模型中的':root'元素已更改。
任何想法,我怎麼能解決這個問題是值得歡迎...
您可以嘗試在pedestal-user郵件列表上發帖以獲取幫助 - https://groups.google.com/forum/#!forum/pedestal-users –
雖然21世紀是一個不錯的地方,但我確信,我會盡力而且不會在那裏得到答案:P – phtrivier
(是的,這是一個脾氣暴躁,幼稚的評論,只是不是正確的一天,對不起) – phtrivier