Liking cljdoc? Tell your friends :D

Alerts

A tiny library in Respo for showing alerts.

Usage

Clojars Project

[respo/alerts "0.1.2"]

This library provides several UI components, so you need to control their visibilities with your own states, for example: {:show-alert? true}.

[respo-alerts.comp.alerts :refer [comp-alert comp-prompt comp-confirm]]

comp-alert is like alert("message") but with a callback function:

(comp-alert "message text"
            (fn [e dispatch! mutate!]
                (dispatch! :some/action "data")
                (mutate! %cursor (assoc state :show-alert? false))))

comp-alert is like confirm("message") but with a callback function returning result:

(comp-confirm "message text"
              (fn [result dispatch! mutate!]
                  (dispatch! :some/action "data")
                  (mutate! %cursor (assoc state :show-confirm? false))
                  (println "confirm in boolean!" result)))

comp-prompt is like prompt("message", "default") but with a callback function returning result. Also notice that comp-prompt has internal states, which is why I use cursor-> in the example:

(cursor-> :prompt
          comp-prompt states "message text" "default text"
                      (fn [result dispatch! mutate!]
                          (dispatch! :some/action "data")
                          (mutate! %cursor (assoc state :show-prompt? false))
                          (println "finish editing!" result)))

Workflow

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

License

MIT

Can you improve this documentation?Edit on GitHub

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

× close