Created
June 30, 2013 21:31
-
-
Save bhauman/5897002 to your computer and use it in GitHub Desktop.
dataflow question for pedestal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ^:shared continue-set-focus.behavior | |
(:require [clojure.string :as string] | |
[io.pedestal.app :as app] | |
[io.pedestal.app.messages :as msg] | |
[io.pedestal.app.util.log :as log])) | |
(defn set-value-transform [old-value message] | |
(:value message)) | |
(defn init-emitter [inputs] | |
[{:greeting {} | |
:button {}} | |
[:transform-enable [:button] | |
:change-message [{msg/type :set-value msg/topic [:greeting] (msg/param :value) {}}]]]) | |
(defn change-to-buttonless-focus [inputs] | |
(log/info "change-to-buttonless focus" inputs) | |
(if (and (= (-> inputs :message :io.pedestal.app.messages/type) :set-value) | |
(not= "Hello World!" (-> inputs :new-model :greeting))) | |
(do | |
(log/info "sending message" inputs) | |
[{msg/type :set-focus msg/topic msg/app-model :name :buttonless}] | |
) | |
) | |
) | |
(def example-app | |
{:version 2 | |
:transform [[:set-value [:greeting] set-value-transform]] | |
:continue [[#{[:greeting]} change-to-buttonless-focus]] | |
:emit [{:in #{[:greeting] [:button]} :fn (app/default-emitter) :mode :always :init init-emitter}] | |
:focus {:default :initial | |
:initial [[:greeting] [:button]] | |
:buttonless [[:greeting]] | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment