(call-mutation-action env k p)
Call a mutation action define in fulcro.client.mutations/mutate.
Call a mutation action define in fulcro.client.mutations/mutate.
(clean-keys env keys)
Set given keys to empty on current ref.
Set given keys to empty on current ref.
(create-entity! {:keys [state ref]} x data & named-parameters)
Create a new entity on the database for a given component. Example:
(fp/defsc TodoItem
[this {::keys []}]
; note the create-entity! data will be used as input for component initial state
; function to get the new entity initial state
{:initial-state (fn [{::keys [title]}]
{::todo-id (random-uuid)
::title title})
:ident [::todo-id ::todo-id]
:query [::todo-id ::title]})
(def todo-item (fp/factory TodoItem {:keyfn ::todo-id}))
(fm/defmutation add-todo [todo]
(action [env]
; append will integrate the new ident into the current ref (which is the todo
; list since it's the transaction reference)
(db.h/create-entity! env TodoItem todo :append ::todo-items)))
(fp/defsc TodoList
[this {::keys [todo-items]}]
{:initial-state (fn [_]
{})
:ident (fn [] [::todo-list "singleton"])
:query [{::todo-items (fp/get-query TodoItem)}]
:css []
:css-include []}
(dom/div
(dom/button {:onClick #(fp/transact! this [`(add-todo {::title "Description"})])})
(mapv todo-item todo-items)))
If you like to send the new entity data directly you can mark it as initialized:
(let [todo (-> (fp/get-initial-state TodoItem todo)
(db.h/initialized))]
(db.h/create-entity! env TodoItem todo :append ::todo-items))
Create a new entity on the database for a given component. Example: (fp/defsc TodoItem [this {::keys []}] ; note the create-entity! data will be used as input for component initial state ; function to get the new entity initial state {:initial-state (fn [{::keys [title]}] {::todo-id (random-uuid) ::title title}) :ident [::todo-id ::todo-id] :query [::todo-id ::title]}) (def todo-item (fp/factory TodoItem {:keyfn ::todo-id})) (fm/defmutation add-todo [todo] (action [env] ; append will integrate the new ident into the current ref (which is the todo ; list since it's the transaction reference) (db.h/create-entity! env TodoItem todo :append ::todo-items))) (fp/defsc TodoList [this {::keys [todo-items]}] {:initial-state (fn [_] {}) :ident (fn [] [::todo-list "singleton"]) :query [{::todo-items (fp/get-query TodoItem)}] :css [] :css-include []} (dom/div (dom/button {:onClick #(fp/transact! this [`(add-todo {::title "Description"})])}) (mapv todo-item todo-items))) If you like to send the new entity data directly you can mark it as initialized: (let [todo (-> (fp/get-initial-state TodoItem todo) (db.h/initialized))] (db.h/create-entity! env TodoItem todo :append ::todo-items))
(defpmutation sym arglist & forms)
Defines a pessimistic mutation. This is adapted to work with the pessimist mutation
system for Shuffle. This works similar to the normal defmutation
, but instead of
doing the optimistic update right after the action, it delays to when the response
is success from the remote. If the remote fails, the UI change is not going to be
applied.
Defines a pessimistic mutation. This is adapted to work with the pessimist mutation system for Shuffle. This works similar to the normal `defmutation`, but instead of doing the optimistic update right after the action, it delays to when the response is success from the remote. If the remote fails, the UI change is not going to be applied.
(init-state state x ident)
Starting from an ident and query, scan the DB initializing the components. This should be used to initialize data loaded from the network with fulcro fetch, this will recursively traverse using query information and merge the initial state with the current data (data load from the server takes priority).
Starting from an ident and query, scan the DB initializing the components. This should be used to initialize data loaded from the network with fulcro fetch, this will recursively traverse using query information and merge the initial state with the current data (data load from the server takes priority).
(initialized data)
Mark data as initialized so the value is not augmented via initial state.
Mark data as initialized so the value is not augmented via initial state.
(query-component this)
(query-component this focus-path)
Run a query against a component with ident. If you provide a path on focus-path, only that path will be queried, and the result will be pulled from the edge of the path.
Run a query against a component with ident. If you provide a path on focus-path, only that path will be queried, and the result will be pulled from the edge of the path.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close