Hello,
I am trying to make a tabbed windowing system within a webpage using
om-bootstrap's "pills" navigation by adding tabs when links get clicked and
removing tabs when an X button on the tabs is clicked.
I need to know how to add and remove data from the global state/store and
create a macro that can be used to declare a tab app component and make it
remove itself when it is no longer alive.
What is the best way to reference the global state and how can I make a
component remove/unmount itself when it gets closed?
Data:
Global store state should look something like:
data : vector -> active-tab-index : integer
current-tabs : vector -> tab-title-string
tab-title-string
...
The tab-title-string would somehow match to the tab app name
Code:
...
;; ===========================================================================
;; Functions
(defn- set-tabs [value]
(om/update! (om/ref-cursor (:name (om/root-cursor state))) {:data :tabs}
value))
(defn- set-tab [name value]
(om/update! (om/ref-cursor (:name (om/root-cursor state))) {:data :tabs name}
value))
(defn- get-tabs [_]
())?
(defn is-active [name]
?)
(defn is-alive [name]
?)
(defn set-active-app-content [& args]
?)
(defn observe-tabs [_]
)
;; ===========================================================================
;; Macros
(defmacro defapp [name local & args]
(defcomponentk name [data owner]
(init-state [_]
local)
(will-mount [_]
(observe-tabs))
(render-state [_ this]
(if-not (is-alive name) REMOVE?!)
(if (is-active name)
(set-active-app-content args)))))
...
--
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.