Skip to content

Instantly share code, notes, and snippets.

@janherich
Last active April 20, 2018 06:23
Show Gist options
  • Save janherich/8ea1cff5dd7e79acf6ac034003d24c05 to your computer and use it in GitHub Desktop.
Save janherich/8ea1cff5dd7e79acf6ac034003d24c05 to your computer and use it in GitHub Desktop.
Extension - events
;; examples of public functions provided by us
(defn add-http-request [{:keys [url method payload]}]
(fn [_]
{:http {:method method
:url url
:payload payload}}))
(defn set-in [{:keys [path value]}]
(fn [_]
{:db (set-in db path value)}))
{:status/add-http-request add-http-request
:status/set-in set-in}
;; hypotetical usage
:views/my-component
[button {:on-press #event [::send-transaction [:status/add-http-request {:url "/transactions"
:method "post"
:payload "test"}]
[:status/set-in {:path [:extension :sent]
:value true}]]}
"Click me!"]
@jeluard
Copy link

jeluard commented Apr 20, 2018

@janherich What's send-transaction in this context and how does it manipulates both add-http-request and set-in ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment