Liking cljdoc? Tell your friends :D

IPFS Re-Frame Effectful Event Handlers

Build Status

ReFrame handlers for

re-frame Effectful Handlers to work with IPFS network's JS HTTP Client, using cljs-ipfs

Installation

;; Add to dependencies
[district0x.re-frame/ipfs-fx "1.0.0"]
(ns my.app.handlers
  (:require 
  [district0x.re-frame.ipfs-fx]))

Usage

The library relies on HTTP API signatures, so follow this docs, Also, return values and responses in callbacks are automatically kebab-cased and keywordized. You can provide IPFS instance as an :inst map entry, in case you'd need more than one connection:

Example call

;;Setup your handlers

(reg-event-fx
::init-ipfs
interceptors
(fn [_ [config]]
  {:ipfs/init config}))                                                                     


(reg-event-fx
::list-files
interceptors
(fn [_ [url]]
  {:ipfs/call {:func "ls"
               :args [url]
               :on-success ::on-list-files-success
               :on-error ::error}}))  
               
(reg-event-fx
::on-list-files-success
interceptors
(fn [{:keys [:db]} [data]]
  {:db (assoc db :files data)}))

    
(dispatch [::init-ipfs {:host "http://127.0.0.1:5001" :endpoint "/api/v0"}])
(dispatch [::list-files "/ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/"])

Can you improve this documentation?Edit on GitHub

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

× close