Liking cljdoc? Tell your friends :D

fulcro.incubator.db-helpers


call-mutation-actionclj/s

(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.
sourceraw docstring

clean-keysclj/s

(clean-keys env keys)

Set given keys to empty on current ref.

Set given keys to empty on current ref.
sourceraw docstring

create-entity!clj/s

(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))
sourceraw docstring

deep-remove-refclj/s

(deep-remove-ref state ref)
source

defpmutationclj/smacro

(defpmutation sym arglist & forms)

Defines a pessimistic mutation. This is adapted to work with ident based pessimist mutation system. 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 ident based pessimist mutation
system. 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.
sourceraw docstring

gen-pessimistic-mutationclj/s

(gen-pessimistic-mutation sym arglist forms)
source

get-mutationclj/s

(get-mutation env k p)
source

init-stateclj/s

(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).
sourceraw docstring

initializedclj/s

(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.
sourceraw docstring

merge-entityclj/s

(merge-entity state x data & named-parameters)
source

mutation-error?clj/s

(mutation-error? this)
(mutation-error? state props)
source

mutation-loading?clj/s

(mutation-loading? this)
source

mutation-responseclj/s

(mutation-response this)
(mutation-response state props)
source

pmutate!clj/s

(pmutate! this mutation params)
source

query-componentclj/s

(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.
sourceraw docstring

remove-edge!clj/s

(remove-edge! {:keys [state ref]} field)
source

resolve-pathclj/s

(resolve-path state path)
source

swap-entity!clj/s

(swap-entity! {:keys [state ref]} & args)
source

swap-in!clj/s

(swap-in! {:keys [state ref]} path & args)
source

transform-remoteclj/s

(transform-remote env ast)
source

vec-remove-indexclj/s

(vec-remove-index i v)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close