Liking cljdoc? Tell your friends :D

com.fulcrologic.fulcro.algorithms.tx-processing

The transaction processing in Fulcro is (intended to be) pluggable. This namespace is the implementation for the default transaction processing . At the present time there is no documentation on how such an override would be written, nor is it necessarily recommended since many of the desirable and built-in behaviors of Fulcro are codified here.

The transaction processing in Fulcro is (intended to be) pluggable. This namespace is the
implementation for the default transaction processing . At the present time there is no documentation on how
such an override would be written, nor is it necessarily recommended since many of the desirable and built-in
behaviors of Fulcro are codified here. 
raw docstring

abort!clj/s

(abort! app abort-id)

Implementation of abort when using this tx processing

Implementation of abort when using this tx processing
sourceraw docstring

abort-elements!clj/s

(abort-elements! {:keys [abort!] :as remote} send-queue abort-id)

Abort any elements in the given send-queue that have the given abort id.

Aborting will cause the network to abort (which will report a result), or if the item is not yet active a virtual result will still be sent for that node.

Returns a new send-queue that no longer contains the aborted nodes.

Abort any elements in the given send-queue that have the given abort id.

Aborting will cause the network to abort (which will report a result), or if the item is not yet active a
virtual result will still be sent for that node.

Returns a new send-queue that no longer contains the aborted nodes.
sourceraw docstring

abort-remote!clj/s

(abort-remote! app-ish remote)

Cause everything in the active network queue for remote to be cancelled. Any result that (finally) appears for aborted items will be ignored. This will cause a hard error to be "received" as the result for everything that is in the send queue of the given remote.

This function is mainly meant for use in development mode when dealing with a buggy remote implementation.

Cause everything in the active network queue for remote to be cancelled. Any result that (finally) appears for aborted
items will be ignored. This will cause a hard error to be "received" as the result for everything
that is in the send queue of the given remote.

This function is mainly meant for use in development mode when dealing with a buggy remote implementation.
sourceraw docstring

activate-submissions!clj/s

(activate-submissions! {:keys [:com.fulcrologic.fulcro.application/runtime-atom]
                        :as app})

Activate all of the transactions that have been submitted since the last activation. After the items are activated a single processing step will run for the active queue.

Activation can be blocked by the tx-node options for things like waiting for the next render frame.

Activate all of the transactions that have been submitted since the last activation. After the items are activated
a single processing step will run for the active queue.

Activation can be blocked by the tx-node options for things like waiting for the next render frame.
sourceraw docstring

active-remotesclj/s

(active-remotes queue remotes)

Calculate which remotes still have network activity to do on the given active queue.

Calculate which remotes still have network activity to do on the given active queue.
sourceraw docstring

add-send!clj/s

(add-send! {:com.fulcrologic.fulcro.application/keys [runtime-atom] :as app}
           {:com.fulcrologic.fulcro.algorithms.tx-processing/keys [id options]
            :as tx-node}
           ele-idx
           remote)

Generate a new send node and add it to the appropriate send queue. Returns the new send node.

Generate a new send node and add it to the appropriate send queue. Returns the new send node.
sourceraw docstring

advance-actions!clj/s

(advance-actions! app
                  {:com.fulcrologic.fulcro.algorithms.tx-processing/keys
                     [id elements]
                   :as node})

Runs any incomplete and non-blocked optimistic operations on a node.

Runs any incomplete and non-blocked optimistic operations on a node.
sourceraw docstring

app->remote-namesclj/s

(app->remote-names app)

Returns a set of the names of the remotes from an app

Returns a set of the names of the remotes from an app
sourceraw docstring

app->remotesclj/s

(app->remotes app)

Returns the remotes map from an app

Returns the remotes map from an app
sourceraw docstring

application-rendered!clj/s

(application-rendered! {:keys [:com.fulcrologic.fulcro.application/runtime-atom]
                        :as app}
                       options)

Should be called after the application renders to ensure that transactions blocked until the next render become unblocked. Schedules an activation.

Should be called after the application renders to ensure that transactions blocked until the next render become
unblocked. Schedules an activation.
sourceraw docstring

build-envclj/s

(build-env app
           {:keys [:com.fulcrologic.fulcro.algorithms.tx-processing/options]
            :as tx-node})
(build-env app
           {:com.fulcrologic.fulcro.algorithms.tx-processing/keys [options]
            :as tx-node}
           addl)
source

combine-sendsclj/s

(combine-sends app remote-name send-queue)

Takes a send queue and returns a map containing a new combined send node that can act as a single network request, along with the updated send queue.

Takes a send queue and returns a map containing a new combined send node that can act as a single network request,
along with the updated send queue.
sourceraw docstring

compute-desired-ast-nodeclj/s

(compute-desired-ast-node app remote tx-node tx-element)

Add the ::desired-ast-nodes and ::transmitted-ast-nodes for remote to the tx-element based on the dispatch for the remote of the original mutation.

Add the ::desired-ast-nodes and ::transmitted-ast-nodes for `remote` to the tx-element based on the dispatch for the `remote` of the original mutation.
sourceraw docstring

default-tx!clj/s

(default-tx! app tx)
(default-tx! {:com.fulcrologic.fulcro.application/keys [runtime-atom] :as app}
             tx
             {:keys [synchronous?] :as options})

Default (Fulcro-2 compatible) transaction submission. The options map can contain any additional options that might be used by the transaction processing (or UI refresh).

Some that may be supported (depending on application settings):

  • :optimistic? - boolean. Should the transaction be processed optimistically?
  • :ref - ident. The component ident to include in the transaction env.
  • :component - React element. The instance of the component that should appear in the transaction env.
  • :refresh - Vector containing idents (of components) and keywords (of props). Things that have changed and should be re-rendered on screen. Only necessary when the underlying rendering algorithm won't auto-detect, such as when UI is derived from the state of other components or outside of the directly queried props. Interpretation depends on the renderer selected: The ident-optimized render treats these as "extras".
  • :only-refresh - Vector of idents/keywords. If the underlying rendering configured algorithm supports it: The components using these are the only things that will be refreshed in the UI. This can be used to avoid the overhead of looking for stale data when you know exactly what you want to refresh on screen as an extra optimization. Idents are not checked against queries.

WARNING: :only-refresh can cause missed refreshes because rendering is debounced. If you are using this for rapid-fire updates like drag-and-drop it is recommended that on the trailing edge (e.g. drop) of your sequence you force a normal refresh via app/render!.

If the options include :ref (which comp/transact! sets), then it will be auto-included on the :refresh list.

NOTE: Fulcro 2 'follow-on reads' are supported and are added to the :refresh entries. Your choice of rendering algorithm will influence their necessity.

Returns the transaction ID of the submitted transaction.

Default (Fulcro-2 compatible) transaction submission. The options map can contain any additional options
that might be used by the transaction processing (or UI refresh).

Some that may be supported (depending on application settings):

- `:optimistic?` - boolean. Should the transaction be processed optimistically?
- `:ref` - ident. The component ident to include in the transaction env.
- `:component` - React element. The instance of the component that should appear in the transaction env.
- `:refresh` - Vector containing idents (of components) and keywords (of props). Things that have changed and should be re-rendered
  on screen. Only necessary when the underlying rendering algorithm won't auto-detect, such as when UI is derived from the
  state of other components or outside of the directly queried props. Interpretation depends on the renderer selected:
  The ident-optimized render treats these as "extras".
- `:only-refresh` - Vector of idents/keywords.  If the underlying rendering configured algorithm supports it: The
  components using these are the *only* things that will be refreshed in the UI.
  This can be used to avoid the overhead of looking for stale data when you know exactly what
  you want to refresh on screen as an extra optimization. Idents are *not* checked against queries.

WARNING: `:only-refresh` can cause missed refreshes because rendering is debounced. If you are using this for
         rapid-fire updates like drag-and-drop it is recommended that on the trailing edge (e.g. drop) of your sequence you
         force a normal refresh via `app/render!`.

If the `options` include `:ref` (which comp/transact! sets), then it will be auto-included on the `:refresh` list.

NOTE: Fulcro 2 'follow-on reads' are supported and are added to the `:refresh` entries. Your choice of rendering
algorithm will influence their necessity.

Returns the transaction ID of the submitted transaction.
sourceraw docstring

dispatch-elementsclj/s

(dispatch-elements tx-node env dispatch-fn)

Run through the elements on the given tx-node and do the side-effect-free dispatch. This generates the dispatch map of things to do on that node.

Run through the elements on the given tx-node and do the side-effect-free dispatch. This generates the dispatch map
of things to do on that node.
sourceraw docstring

dispatch-result!clj/s

(dispatch-result! app
                  tx-node
                  {:com.fulcrologic.fulcro.algorithms.tx-processing/keys
                     [results dispatch desired-ast-nodes transmitted-ast-nodes
                      original-ast-node]
                   :as tx-element}
                  remote)

Figure out the dispatch routine to trigger for the given network result. If it exists, send the result to it.

Returns the tx-element with the remote marked complete.

Figure out the dispatch routine to trigger for the given network result.  If it exists, send the result
to it.

Returns the tx-element with the remote marked complete.
sourceraw docstring

distribute-element-results!clj/s

(distribute-element-results!
  app
  tx-node
  {:keys [:com.fulcrologic.fulcro.algorithms.tx-processing/results
          :com.fulcrologic.fulcro.algorithms.tx-processing/complete?]
   :as tx-element})

Distribute results and mark the remotes for those elements as complete.

Distribute results and mark the remotes for those elements as complete.
sourceraw docstring

distribute-results!clj/s

(distribute-results!
  app
  {:keys [:com.fulcrologic.fulcro.algorithms.tx-processing/elements]
   :as tx-node})

Walk all elements of the tx-node and call result dispatch handlers for any results that have not been distributed.

Walk all elements of the tx-node and call result dispatch handlers for any results that have
not been distributed.
sourceraw docstring

element-with-workclj/s

(element-with-work
  remote-names
  {:keys [:com.fulcrologic.fulcro.algorithms.tx-processing/dispatch
          :com.fulcrologic.fulcro.algorithms.tx-processing/started?]
   :as element})

Returns a txnode element iff it has remaining (remote) work that has not been queued. Returns nil if there is no such element.

remote-names is the set of legal remote names.

Returns a txnode element iff it has remaining (remote) work that has not been queued. Returns nil if there
 is no such element.

remote-names is the set of legal remote names.
sourceraw docstring

every-ast?clj/s

(every-ast? ast-node-or-tree test)

Check if the given test predicate is true for an AST node or for all the immediate children of an AST tree.

Check if the given `test` predicate is true for an AST node or for all the immediate children of an AST tree.
sourceraw docstring

extract-parallelclj/s

(extract-parallel sends)

Splits the given send queue into two send queues: [parallel-items sequential-items].

Splits the given send queue into two send queues:
[parallel-items sequential-items].
sourceraw docstring

fully-complete?clj/s

(fully-complete? app
                 {:keys
                    [:com.fulcrologic.fulcro.algorithms.tx-processing/elements]
                  :as tx-node})
source

idle-node?clj/s

(idle-node? {:keys [:com.fulcrologic.fulcro.algorithms.tx-processing/elements]
             :as tx-node})

Returns true if the given node has no active network operations.

Returns true if the given node has no active network operations.
sourceraw docstring

mutation-ast?clj/s

(mutation-ast? ast-node-or-tree)

Returns true if the given AST node or tree represents a mutation or sequence of mutations.

Returns true if the given AST node or tree represents a mutation or sequence of mutations.
sourceraw docstring

net-send!clj/s

(net-send! app send-node remote-name)

Process the send against the user-defined remote. Catches exceptions and calls error handler with status code 500 if the remote itself throws exceptions.

Process the send against the user-defined remote. Catches exceptions and calls error handler with status code 500
if the remote itself throws exceptions.
sourceraw docstring

process-queue!clj/s

(process-queue!
  {:com.fulcrologic.fulcro.application/keys [state-atom runtime-atom] :as app})

Run through the active queue and do a processing step.

Run through the active queue and do a processing step.
sourceraw docstring

process-send-queues!clj/s

(process-send-queues! {:com.fulcrologic.fulcro.application/keys [runtime-atom]
                       :as app})

Process the send queues against the remotes. Updates the send queues on the app and returns the updated send queues.

Process the send queues against the remotes. Updates the send queues on the app and returns the updated send queues.
sourceraw docstring

process-tx-node!clj/s

(process-tx-node! app
                  {:keys
                     [:com.fulcrologic.fulcro.algorithms.tx-processing/options]
                   :as tx-node})
source

query-ast?clj/s

(query-ast? ast-node-or-tree)

Returns true if the given AST node or tree represents a mutation or sequence of mutations.

Returns true if the given AST node or tree represents a mutation or sequence of mutations.
sourceraw docstring

queue-element-sends!clj/s

(queue-element-sends!
  app
  tx-node
  {:keys [:com.fulcrologic.fulcro.algorithms.tx-processing/idx
          :com.fulcrologic.fulcro.algorithms.tx-processing/dispatch
          :com.fulcrologic.fulcro.algorithms.tx-processing/started?]})

Queue all (unqueued) remote actions for the given element. Returns the (possibly updated) node.

Queue all (unqueued) remote actions for the given element.  Returns the (possibly updated) node.
sourceraw docstring

queue-next-send!clj/s

(queue-next-send! app
                  {:keys
                     [:com.fulcrologic.fulcro.algorithms.tx-processing/elements]
                   :as tx-node})

Assumes tx-node is to be processed pessimistically. Queues the next send if the node is currently idle on the network and there are any sends left to do. Adds to the send queue, and returns the updated tx-node.

Assumes tx-node is to be processed pessimistically. Queues the next send if the node is currently idle
on the network and there are any sends left to do. Adds to the send queue, and returns the updated
tx-node.
sourceraw docstring

queue-sends!clj/s

(queue-sends! app
              {:keys [:com.fulcrologic.fulcro.algorithms.tx-processing/options
                      :com.fulcrologic.fulcro.algorithms.tx-processing/elements]
               :as tx-node})

Finds any item(s) on the given node that are ready to be placed on the network queues and adds them. Non-optimistic multi-element nodes will only queue one remote operation at a time.

Finds any item(s) on the given node that are ready to be placed on the network queues and adds them. Non-optimistic
multi-element nodes will only queue one remote operation at a time.
sourceraw docstring

record-result!clj/s

(record-result! app txn-id ele-idx remote result)
(record-result! {:com.fulcrologic.fulcro.application/keys [runtime-atom]
                 :as app}
                txn-id
                ele-idx
                remote
                result
                result-key)

Record a network result on the given txn/element. If result-key is given it is used, otherwise defaults to ::results. Also removes the network send from the send queue so that remaining items can proceed, and schedules send processing.

Record a network result on the given txn/element.
If result-key is given it is used, otherwise defaults to ::results. Also removes the network send from the send
queue so that remaining items can proceed, and schedules send processing.
sourceraw docstring

remotes-active-on-nodeclj/s

(remotes-active-on-node
  {:com.fulcrologic.fulcro.algorithms.tx-processing/keys [elements] :as tx-node}
  remotes)

Given a tx node and the set of legal remotes: returns a set of remotes that are active on that node.

Given a tx node and the set of legal remotes: returns a set of remotes that are active on that node.
sourceraw docstring

remove-send!clj/s

(remove-send! {:com.fulcrologic.fulcro.application/keys [runtime-atom] :as app}
              remote
              txn-id
              ele-idx)

Removes the send node (if present) from the send queue on the given remote.

Removes the send node (if present) from the send queue on the given remote.
sourceraw docstring

requested-refreshesclj/s

(requested-refreshes app queue)
source

run-actions!clj/s

(run-actions! app
              {:com.fulcrologic.fulcro.algorithms.tx-processing/keys [id
                                                                      elements]
               :as node})
source

schedule-activation!clj/s

(schedule-activation! app)
(schedule-activation! app tm)

Schedule activation of submitted transactions. The default implementation copies all submitted transactions onto the active queue and immediately does an active queue processing step. If tm is not supplied (in ms) it defaults to 10ms.

Schedule activation of submitted transactions.  The default implementation copies all submitted transactions onto
the active queue and immediately does an active queue processing step.  If `tm` is not supplied (in ms) it defaults to 10ms.
sourceraw docstring

schedule-queue-processing!clj/s

(schedule-queue-processing! app)
(schedule-queue-processing! app tm)

Schedule a processing of the active queue, which will advance the active transactions by a step. If tm is not supplied (in ms) it defaults to 10ms.

Schedule a processing of the active queue, which will advance the active transactions by a step.
If `tm` is not supplied (in ms) it defaults to 10ms.
sourceraw docstring

schedule-sends!clj/s

(schedule-sends! app)
(schedule-sends! app tm)

Schedule actual network activity. If tm is not supplied (in ms) it defaults to 0ms.

Schedule actual network activity. If `tm` is not supplied (in ms) it defaults to 0ms.
sourceraw docstring

sort-queue-writes-before-readsclj/s

(sort-queue-writes-before-reads send-queue)

Sort function on a send queue. Leaves any active nodes in front, and sorts the remainder of the queue so that writes appear before reads, without changing the relative order in blocks of reads/writes.

Sort function on a send queue. Leaves any active nodes in front, and sorts the remainder of the queue so that writes
appear before reads, without changing the relative order in blocks of reads/writes.
sourceraw docstring

top-keysclj/s

(top-keys {:keys [type key children] :as ast})
source

transact-sync!clj/s

(transact-sync! app tx {:keys [component ref] :as options})

Run the optimistic action(s) of a transaction synchronously. It is primarily used to deal with controlled inputs, since they have issues working asynchronously, so ideally the mutation in question will not have remote action (though they are allowed to).

NOTE: any remote behaviors of tx will still be async.

This function:

  • Runs the optimistic side of the mutation(s)
  • IF (and only if) one or more of the mutations has more sections than just an action then it submits the mutation to the normal transaction queue, but with the optimistic part already done.
  • This functions does not queue a render refresh (though if the normal transaction queue is updated, it will queue tx remote processing, which will trigger a UI refresh).

If you pass it an on-screen instance that has a query and ident, then this function tunnel updated UI props synchronously to that component so it can refresh immediately and avoid DOM input issues.

Returns the new component props or the final state map if no component was used in the transaction.

Run the optimistic action(s) of a transaction synchronously. It is primarily used to deal with controlled inputs, since they
have issues working asynchronously, so ideally the mutation in question will *not* have remote action (though they
are allowed to).

NOTE: any *remote* behaviors of `tx` will *still be async*.

This function:

* Runs the optimistic side of the mutation(s)
* IF (and only if) one or more of the mutations has more sections than just an `action` then it submits the mutation to the normal transaction queue,
  but with the optimistic part already done.
* This functions *does not* queue a render refresh (though if the normal transaction queue is updated, it will queue tx remote processing, which will trigger a UI refresh).

If you pass it an on-screen instance that has a query and ident, then this function tunnel updated UI props synchronously to that
component so it can refresh immediately and avoid DOM input issues.

Returns the new component props or the final state map if no component was used in the transaction.
sourceraw docstring

tx-nodeclj/s

(tx-node tx)
(tx-node tx options)
source

update-progress!clj/s

(update-progress! app
                  {:keys
                     [:com.fulcrologic.fulcro.algorithms.tx-processing/elements]
                   :as tx-node})

Report all progress items to any registered progress dispatch and clear them from the tx-node. Returns the updated tx-node.

Report all progress items to any registered progress dispatch and clear them from the tx-node.
Returns the updated tx-node.
sourceraw docstring

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

× close