Liking cljdoc? Tell your friends :D

Respo Message

Message component for Respo apps.

Demo http://repo.respo.site/message/

Usage

Clojars Project

[respo/message "0.2.3"]

You will need these functions:

respo-message.updater/add-one
respo-message.updater/remove-one
respo-message.comp.msg-list/comp-msg-list

For the store part, it's supposed to have the field :messages and two actions:

(defonce store-ref (atom {:messages []}))

(defn dispatch! [op op-data]
  (println "dispatch!" op op-data)
  (let [op-id (id!)
        new-store (case op
                    :message/add
                      (add-one @store-ref op
                       {:id op-id, :kind (rand-nth kinds), :text (rand-nth words)})
                    :message/remove (remove-one @store-ref op op-data)
                    @store-ref)]
    (reset! store-ref new-store)))

Probably you want to write by yourself:

(defn remove-one [store op op-data]
  (update store :messages (fn [messages] (subvec messages 0 op-data))))

(defn add-one [store op op-data]
  (update store :messages (fn [messages] (conj messages op-data))))

Mounting the component into tree is simpler:

(def op-remove :x/remove)

(comp-msg-list (:messages store) op-remove)

By default the "removing" action use :message/remove. You can set it with op-remove.

Message types are corresponded to those in Respo UI:

  • attractive
  • irreversible
  • attentive
  • verdant
  • warm

Develop

Workflow https://github.com/mvc-works/stack-workflow

License

MIT

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close