All Projects → akiroz → Re Frame Storage

akiroz / Re Frame Storage

Licence: mit
re-frame interceptors for browser local storage

Programming Languages

clojure
4091 projects
clojurescript
191 projects

Projects that are alternatives of or similar to Re Frame Storage

Vue Local Storage
Vue.js localStorage plugin with types support
Stars: ✭ 639 (+1352.27%)
Mutual labels:  localstorage
Re Frame Cookie Fx
Om nom nom nom.
Stars: ✭ 17 (-61.36%)
Mutual labels:  re-frame
Re Pollsive
Re-pollsive is a clojurescript library that handles polling events for re-frame applications
Stars: ✭ 27 (-38.64%)
Mutual labels:  re-frame
Histore
🏬 200b key-value store backed by navigation state
Stars: ✭ 683 (+1452.27%)
Mutual labels:  localstorage
Tableexport
The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files.
Stars: ✭ 781 (+1675%)
Mutual labels:  localstorage
Broadcast Channel
📡 BroadcastChannel to send data between different browser-tabs or nodejs-processes 📡
Stars: ✭ 843 (+1815.91%)
Mutual labels:  localstorage
Storage
Asynchronous browser storage with multiple back-ends (IndexedDB, WebSQL, localStorage)
Stars: ✭ 612 (+1290.91%)
Mutual labels:  localstorage
Remember Scroll
🎯 A plugin using localStorage to remember element scroll-position when closed the page.
Stars: ✭ 33 (-25%)
Mutual labels:  localstorage
Storagedb
MongoDB-like API for HTML5 Storage (localStorage and sessionStorage)
Stars: ✭ 16 (-63.64%)
Mutual labels:  localstorage
React Native Localstorage
Manage LocalStorage items in a web environment
Stars: ✭ 11 (-75%)
Mutual labels:  localstorage
Re Com
A ClojureScript library of reusable components for Reagent
Stars: ✭ 690 (+1468.18%)
Mutual labels:  re-frame
Vue Music Player
🎵Vue.js写一个音乐播放器+📖One(一个).A music player + One by Vue.js
Stars: ✭ 729 (+1556.82%)
Mutual labels:  localstorage
Aframe Persist Component
Persisting Aframe attribute data using localStorage
Stars: ✭ 10 (-77.27%)
Mutual labels:  localstorage
Tyto
manage and organise things
Stars: ✭ 662 (+1404.55%)
Mutual labels:  localstorage
Use Persisted State
A custom React Hook that provides a multi-instance, multi-tab/browser shared and persistent state.
Stars: ✭ 943 (+2043.18%)
Mutual labels:  localstorage
Cljfx
Declarative, functional and extensible wrapper of JavaFX inspired by better parts of react and re-frame
Stars: ✭ 624 (+1318.18%)
Mutual labels:  re-frame
Tincture
Frontend development toolkit for ClojureScript
Stars: ✭ 24 (-45.45%)
Mutual labels:  re-frame
Featherpasswordmanager
Highly portable extremely light-weight password manager that stores all your passwords in a local encrypted file.
Stars: ✭ 39 (-11.36%)
Mutual labels:  localstorage
Re Frame Forward Events Fx
A re-frame effects handler for listening-for and then post-processing dispatched events
Stars: ✭ 30 (-31.82%)
Mutual labels:  re-frame
Proxy Storage
Provides an adapter for storage mechanisms (cookies, localStorage, sessionStorage, memoryStorage) and implements the Web Storage interface
Stars: ✭ 10 (-77.27%)
Mutual labels:  localstorage

re-frame-storage

Clojars Project GitHub license Build Status

A very simple re-frame wrapper around storage-atom for persisting app state.

Depends on re-frame >= 0.8.0.

Usage

There are 2 ways to use this:

1. As individual re-frame fx & cofx

(ns my-app
  (:require [akiroz.re-frame.storage :refer [reg-co-fx!]]))

;; both :fx and :cofx keys are optional, they will not be registered if unspecified.
(reg-co-fx! :my-app         ;; local storage key
            {:fx :store     ;; re-frame fx ID
             :cofx :store}) ;; re-frame cofx ID

;; ...

(reg-event-fx
  :read-foo-store-bar
  [(inject-cofx :store)]
  (fn [{:keys [store]} _]
    (print (:foo store))
    {:store (assoc store :bar "qux")}))

2. As a re-frame interceptor that automatically persists part of your app-db

(ns my-app
  (:require [akiroz.re-frame.storage :refer [persist-db]]))

;; define a custum reg-event-db
;; local storage key is :my-app
;; everything inside the db's :persistent key is automatically stored and retreived.
(defn my-reg-event-db
  [event-id handler]
  (reg-event-fx
    event-id
    [(persist-db :my-app :persistent)]
    (fn [{:keys [db]} event-vec]
      {:db (handler db event-vec)})))

;; ...

(my-reg-event-db
  :read-foo-store-bar
  (fn [db _]
    (print (get-in db [:persistent :foo]))
    (assoc-in db [:persistent :bar] "qux")))

;; Or, if you want to persist multiple DB keys:

(defn my-reg-event-db
  [event-id handler]
  (reg-event-fx
    event-id
    [(persist-db-keys :my-app [:persistent-1 :persistent-2])]
    (fn [{:keys [db]} event-vec]
      {:db (handler db event-vec)})))

;; May want an init helper to dispatch on app init

(my-reg-event-db :init (fn [db] db))

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].