(dispatch pro-name payload)
Dispatches socket, req and data to procedure. (dispatch ::get-employee-list-by-company {:req req :socket socket :data "Company A" :send-fn (fn [socket result] (s/put! socket result))})
Dispatches socket, req and data to procedure. (dispatch ::get-employee-list-by-company {:req req :socket socket :data "Company A" :send-fn (fn [socket result] (s/put! socket result))})
(dispatch-sync pro-name payload)
Sync version of dispatch function that returns a response. It's a blocking operation. It should be used inside reg-pros (when there is a need for calling other reg-pros with different params).
Sync version of dispatch function that returns a response. It's a blocking operation. It should be used inside reg-pros (when there is a need for calling other reg-pros with different params).
(reg-pro name-kw doc-string? deps? data-&-response-schema-map? body)
Defines a procedure with any doc-string or deps added to the procedure map. data-&-response-schema-map? defines a map with optional keys :data and :response that contain data or response schema.
e.g.; (reg-pro :current-user (fn [{:keys [req]}] (println "Request: " req) {:user (get-user-by-username (-> req :query-params (get "username")))}))
(reg-pro :get-current-users-favorite-songs [:current-user] {:data [:map [:category string?]] :response [:map [:songs (vector string?)]]} (fn [current-user {:keys [req data]}] (let [user-id (-> current-user :user :id) music-category (:category data)] {:songs (get-favorite-songs-by-user-id-and-music-category user-id music-category)})))
Defines a procedure with any doc-string or deps added to the procedure map. data-&-response-schema-map? defines a map with optional keys :data and :response that contain data or response schema. e.g.; (reg-pro :current-user (fn [{:keys [req]}] (println "Request: " req) {:user (get-user-by-username (-> req :query-params (get "username")))})) (reg-pro :get-current-users-favorite-songs [:current-user] {:data [:map [:category string?]] :response [:map [:songs (vector string?)]]} (fn [current-user {:keys [req data]}] (let [user-id (-> current-user :user :id) music-category (:category data)] {:songs (get-favorite-songs-by-user-id-and-music-category user-id music-category)})))
(register-validation-fn! f)
Validation function (optional) can only return true, false and a string. If it returns string which indicates validation failed with an error message.
(register-validation-fn! (fn [schema data] (or (malli/validate schema data) (malli/humanize (malli/explain schema data)))))
Validation function (optional) can only return true, false and a string. If it returns string which indicates validation failed with an error message. (register-validation-fn! (fn [schema data] (or (malli/validate schema data) (malli/humanize (malli/explain schema data)))))
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close