-
Notifications
You must be signed in to change notification settings - Fork 0
Creating a Tab Capability
At a minimum, a tab/capability has two parts: a client side part and a server side part.
#Client Side
The client side is responsible for the display when the tab is selected. For example, welcome/client.cljs.hl contains the following:
(ns welcome.client
(:require
[tiples.login :as login]))
(def do-welcome
(h2 (text "Hello ~{(:full-name (:welcome login/user-data))}.")))
(defmethod login/add-element :welcome [_] (do-welcome))
The add-element method creates the DOM elements to be displayed. In effect, all the DOM elements of all the tabs are created when the page is loaded. But the tab is only visible when the user has selected it.
#Server Side
The server side is responsible for defining the ordering of the tab/capability relative to other tabs/capabilities. The server and client sides are also responsible for processing any messages sent by the other. For example welcome/server.clj contains the following code:
(ns welcome.server
(:require [tiples.users :as users]))
(users/add-capability :welcome)
The add-capability function includes the :welcome keyword in the vector of capability keywords. This vector is passed to the client side at startup.
The welcome tab/capability makes use of no other message passing. So the code is quite brief.