A pluggable transaction processing system that attempts to batch reads. Requires that the server be modified to support sequences of transactions.
A pluggable transaction processing system that attempts to batch reads. Requires that the server be modified to support sequences of transactions.
(abort! app abort-id)
Implementation of abort when using this tx processing
Implementation of abort when using this tx processing
(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.
(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.
(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.
(add-send! {:com.fulcrologic.fulcro.application/keys [runtime-atom] :as app}
{:com.fulcrologic.fulcro.algorithms.tx-processing/keys [id options
parallel?]
: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.
(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.
(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
(app->remotes app)
Returns the remotes map from an app
Returns the remotes map from an app
(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.
(batchable? to-send leader)
Returns true when ALL of the ::txn/send-node entries in to-send
can be batched into an existing batch.
Returns true when ALL of the ::txn/send-node entries in `to-send` can be batched into an existing batch.
(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)
(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.
(compute-desired-ast-node app remote tx-node tx-element)
Add the ::txn/desired-ast-nodes and ::txn/transmitted-ast-nodes for remote
to the tx-element based on the dispatch for the remote
of the original mutation.
Add the ::txn/desired-ast-nodes and ::txn/transmitted-ast-nodes for `remote` to the tx-element based on the dispatch for the `remote` of the original mutation.
(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.
(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.
(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.
(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.
(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.
(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.
(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.
(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].
(fully-complete? app
{:keys
[:com.fulcrologic.fulcro.algorithms.tx-processing/elements]
:as tx-node})
(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.
(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.
(mutation-node? {:com.fulcrologic.fulcro.algorithms.tx-processing/keys [ast]})
Returns true if the given transaction node represents one or more mutations.
Returns true if the given transaction node represents one or more mutations.
(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.
(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.
(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.
(process-tx-node! app
{:keys
[:com.fulcrologic.fulcro.algorithms.tx-processing/options]
:as tx-node})
(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.
(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.
(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.
(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.
(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 ::txn/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 ::txn/results. Also removes the network send from the send queue so that remaining items can proceed, and schedules send processing.
(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.
(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.
(run-actions! app
{:com.fulcrologic.fulcro.algorithms.tx-processing/keys [id
elements]
:as node})
(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.
(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.
(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.
(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.
(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:
action
then it submits the mutation to the normal transaction queue,
but with the optimistic part already done.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.
(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.
(with-batched-reads app)
(with-batched-reads app remotes)
Modify the given fulcro app so that it does reads in batches when possible. Requires server support (which is provided by Fulcro's handle-api-request), and a remote that can handle raw requests (see the latest http-remote).
Defaults to enabling batching on all remotes, but if any of your client-side remote code or servers do not support
batching, pass the remotes
option, which is a set of keywords that names the remotes on which batching should
be enabled.
Modify the given fulcro app so that it does reads in batches when possible. Requires server support (which is provided by Fulcro's handle-api-request), and a remote that can handle raw requests (see the latest http-remote). Defaults to enabling batching on all remotes, but if any of your client-side remote code or servers do not support batching, pass the `remotes` option, which is a set of keywords that names the remotes on which batching should be enabled.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close