   (:require [cljs.core.match :refer-macros [match]]))
 
 (defn -wrap-control
-  [control storage key blacklist]
-  (fn wrapped-control
+  [component-control storage key blacklist]
+  (fn control
     [model signal dispatch]
     (letfn [(save
               [result]

            (save-and-control
              [model signal]
              (save model)                                  ; persist current model in case no action is dispatched
              (control model signal dispatch-and-save))]
      (if-not (= signal :on-connect)
        ; hand signal further to component
        (save-and-control model signal)

            ; else - update model and hand it with signal further to component
            (let [new-model (merge storage-model (select-keys model blacklist))]
              (dispatch [::-reset-from-storage new-model])
              (component-control new-model signal dispatch-and-save))))))))

(defn -wrap-reconcile
  [component-reconcile]
  (fn reconcile
    [model action]
    (match action
           [::-reset-from-storage data]
           data

           :else
           (component-reconcile model action))))

(defn wrap
  "On :on-connect signal middleware will load the model from storage and send the signal further with updated model to the component.
