Liking cljdoc? Tell your friends :D

Clojars Project GitHub issues License

Clipboard Effect Handler for re-frame

This re-frame library contains an Effect Handler for interacting with the system clipboard.

Keyed ::re-frame.clipboard-fx/copy, it wraps browsers' native Document.execCommand() API.

Currently only the copy operation is supported. Future work includes supporting the Clipboard API and support for more operations.

Quick Start

Step 1. Add Dependency

Add the following project dependency: Clojars Project

Requires re-frame >= 0.8.0.

Step 2. Registration and Use

In the namespace where you register your event handlers, prehaps called events.cljs, you have two things to do.

First, add this require to the ns:

(ns app.events
  (:require
   ...
   [re-frame.clipboard-fx :as clipboard-fx]
   ...))

Second, write an event handler which uses this effect:

(reg-event-fx
  :handler-with-clipboard
  (fn [{:keys [db]} _]
    {::clipboard-fx/copy {:text       (get-in db [:some :path :to :text])
                          :on-success [:clipboard-success]
                          :on-failure [:clipboard-failure]}}))

License

Copyright © 2020-2021 Isaac Johnston.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Can you improve this documentation?Edit on GitHub

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

× close