From 3c009b2da1363d62f3b47354fd85b870eca3662c Mon Sep 17 00:00:00 2001 From: Hugo Duncan Date: Mon, 8 Sep 2014 14:43:51 -0400 Subject: [PATCH] Pass default atom to local-storage-atom Allow use of local-storage-atom with non-core atom implementations, like reagent's atom. This is a breaking change that changes the expected argument type from a default map to an atom o fthe required type containing the default values. --- .../src/com/palletops/bakery/local_storage_atom.cljs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/local-storage-atom/src/com/palletops/bakery/local_storage_atom.cljs b/local-storage-atom/src/com/palletops/bakery/local_storage_atom.cljs index 9e79b7e..a70d17d 100644 --- a/local-storage-atom/src/com/palletops/bakery/local_storage_atom.cljs +++ b/local-storage-atom/src/com/palletops/bakery/local_storage_atom.cljs @@ -11,12 +11,11 @@ "Return a component that is an atom backed by local storage (if supported). `default` is used to initialise the atom if it is not already in local storage. The ILifecycle protocol is not implemented." - {:sig [[schema/Any schema/Keyword :- (protocol IDeref)]]} - [default key] - (let [app-state-atom (atom default)] - (if js/localStorage - (local-storage app-state-atom key) - app-state-atom))) + {:sig [[(protocol IDeref) schema/Keyword :- (protocol IDeref)]]} + [default-atom key] + (if js/localStorage + (local-storage default-atom key) + default-atom)) ;; define a value reference type that is serialised as nil (deftype Filtered [v]