Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effect functions do not trigger as described in documentation (app tutorial) #8

Open
avescodes opened this issue Feb 14, 2014 · 0 comments
Labels

Comments

@avescodes
Copy link

The documentation for pedestal states, that effect functions configured in dataflow description under :effect key should trigger when value in data model at configured path changes.
However, i'm experiencing different behavior, such that all effect functions are called first time even when there is no data (and therefore no change) at configured path.

Consider following code:

(defn init-app []
  [{:app
     {:control {:menu {:value nil}}
      :new-workflow {:form
                     {:transforms 
                      {:send [{msg/type :set-sending msg/topic [:app :new-workflow :form] (msg/param :value) {}}]}}}
      :workflows {:value nil}
      :instances {:value nil}
      :selected-workflow {:value nil}
      :selected-instance {:value nil}}}])

(def workflow-app
  {:version 2
   :transform [[:set-value [:**] set-value-transform]
                    [:set-sending [:**] set-sending]
                    [:clear-sending [:**] clear-sending]]
   :derive #{[{[:app :control :selected] :selected [:app :control :menu] :menu} [:app :control :menu] select-tab-menu :map]
             [{[:app :workflows] :workflows [:app :instances :*] :changed-instances} [:app :instances] add-wf-to-instance :map]
             [{[:app :workflows] :workflows [:app :selected-workflow] :workflow-id} [:app :selected-workflow] select-workflow :map]
             [{[:app :instances] :instances [:app :selected-instance] :instance-id} [:app :selected-instance] select-instance :map]}
   :effect #{[#{[:app :new-workflow :form :sending]} publish-new-workflow :single-val]}
   :emit [{:init init-app}
             [#{[:app :control :menu :*]
                 [:app :new-workflow :form :sending]
                 [:app :workflows :*]
                 [:app :instances :*]
                 [:app :selected-workflow :*]
                 [:app :selected-instance :*]} (app/default-emitter [])]]
   :focus {:add-workflow [[:app :control] [:app :new-workflow]]
              :list-workflows [[:app :control] [:app :workflows]]
              :list-instances [[:app :control] [:app :instances]]
              :detail-workflow [[:app :control] [:app :selected-workflow]]
              :detail-instance [[:app :control] [:app :selected-instance]]
              :default (get-focus-key initial-menu)}})

Even when there is no data at the path [:app :new-workflow :form :sending] at the initialisation, the function publish-new-workflow is called with nil argument for the first time, after that it works fine, and the function is called only when data at path [:app :new-workflow :form :sending] changes.

Operating System: Ubuntu 13.10 Saucy Salamander
Leiningen version: Leiningen 2.3.3 on Java 1.7.0_45 Java HotSpot(TM) 64-Bit Server VM
Pedestal version: 0.2.2-SNAPSHOT
Steps to reproduce: Define dataflow with effect function under :effect key and configure the function to use the path in the data model with no starting data, observe how the function is called with nil value for the first time after building the dataflow and consuming effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant