Liking cljdoc? Tell your friends :D

com.fulcrologic.fulcro.data-fetch


data-state?clj/s

(data-state? state)

Is the given parameter a load marker?

Is the given parameter a load marker?
sourceraw docstring

failed?clj/s

(failed? marker)

Is the given load marker indicate failed?

WARNING: This function is current unimplemented and will be removed. The new way of dealing with failure is to define an error-action for the load in question and modify your own state. You can also override

Is the given load marker indicate failed?

WARNING: This function is current unimplemented and will be removed.  The new way of dealing with failure is to
define an `error-action` for the load in question and modify your own state. You can also override
sourceraw docstring

finish-load!clj/s

(finish-load! {:keys [app result] :as env}
              {:keys [query ok-action post-mutation post-mutation-params
                      post-action target marker source-key]})

Default processing when a load finishes successfully (called internally).

Removes any load marker, then either:

  • Runs the ok-action (if defined).
  • Does normal post-processing (if the was no ok-action):
    • Merges the load result
    • Processes desired targets
    • Runs the post-mutation (if defined)
    • Runs the post-action (if defined)
Default processing when a load finishes successfully (called internally).

Removes any load marker, then either:

- Runs the `ok-action` (if defined).
- Does normal post-processing (if the was no ok-action):
     - Merges the load result
     - Processes desired targets
     - Runs the post-mutation (if defined)
     - Runs the post-action (if defined)
sourceraw docstring

loadclj/s

DEPRECATED. Use load!

DEPRECATED. Use `load!`
sourceraw docstring

load!clj/s

(load! app-or-comp server-property-or-ident class-or-factory)
(load! app-or-comp server-property-or-ident class-or-factory config)

Load data from the server.

This function triggers a server interaction and normalizes the server response into your app state database. During operation it also adds (by default) fetch markers into the app state so you can show busy indicators on the UI components that are waiting for data. The :target parameter can be used to place the data somewhere besides app state root (which is the default).

The server will receive a query of the form: [({server-property (comp/get-query class-or-factory)} params)], which a Fulcro parser will correctly parse as a join on server-property with the given subquery and params. See the AST and instructions on parsing queries in the developer's guide.

Parameters:

  • app-or-comp : A component instance, Fulcro application, or reconciler
  • server-property-or-ident : A keyword or ident that represents the root of the query to send to the server. If this is an ident you are loading a specific entity from the database into a local app db table. A custom target will be ignored.
  • class-or-factory : A component that implements IQuery, or a factory for it (if using dynamic queries). This will be combined with server-property into a join for the server query. Needed to normalize results. class-or-factory can be nil, in which case the resulting server query will not be a join.
  • config : A map of load configuration parameters.

Config (all optional):

  • target - An assoc-in path at which to put the result of the Subquery (as an edge (normalized) or value (not normalized)). Can also be special targets (multiple-targets, append-to, prepend-to, or replace-at). If you are loading by keyword (into root), then this relocates the result (ident or value) after load. When loading an entity (by ident), then this option will place additional idents at the target path(s) that point to that entity.

  • initialize - REMOVED. Use component pre-merge instead.

  • remote - Optional. Keyword name of the remote that this load should come from.

  • params - Optional parameters to add to the generated query

  • marker - ID of marker. Normalizes a load marker into app state so you can see progress.

  • refresh - A list of things in the UI to refresh. Depends on rendering optimization.

  • parallel - Send the load out-of-order (immediately) without waiting for other loads in progress.

  • post-mutation - DEPRECATED. use post-action. A mutation (symbol) to run after the data is merged. Note, if target is supplied be sure your post mutation should expect the data at the targeted location. The env of that mutation will be the env of the load (if available), but will also include :load-request.

  • post-mutation-params - An optional map that will be passed to the post-mutation when it is called. May only contain raw data, not code!

  • ok-action - WARNING: OVERRIDES ALL DEFAULT OK BEHAVIOR (post-mutation, merge, clearing load marker)! A lambda that will receive the remote result in a mutation env parameter (fn [env] ...).

  • post-action - A lambda that will receive the remote result in a mutation env parameter (fn [env] ...). Called after success, like post-mutation, but as a lambda.

  • error-action - A lambda that will receive the errant result (bad server status code/body) in a mutation env parameter (fn [env] ...). Like the error-action section of mutations.

  • fallback - A mutation (symbol) to run if there is a server/network error. The env of the fallback will be like a mutation env, and will include a :result key with the real result from the server.

  • update-query - A optional function that can transform the component query before sending to remote. For example, to focus a subquery using update-query: {:update-query #(eql/focus-subquery % [:my {:sub [:query]}])}

    Removing properties (like previous :without option): {:update-query #(df/elide-query-nodes % #{:my :elisions})}

  • focus - Focus the query along a path. See eql/focus-subquery.

  • without - A set of keys to remove (recursively) from the query.

  • abort-id - TODO. Normally use txn id, which is returned by this function.

Returns a transaction ID, which can be used with abort

Load data from the server.

This function triggers a server interaction and normalizes the server response into your app state database. During
operation it also adds (by default) fetch markers into the app state so you can show busy indicators on the UI
components that are waiting for data. The `:target` parameter can be used to place the data somewhere besides app
state root (which is the default).

The server will receive a query of the form: [({server-property (comp/get-query class-or-factory)} params)], which
a Fulcro parser will correctly parse as a join on server-property with the given subquery and params. See the AST and
instructions on parsing queries in the developer's guide.

Parameters:
- `app-or-comp` : A component instance, Fulcro application, or reconciler
- `server-property-or-ident` : A keyword or ident that represents the root of the query to send to the server. If this is an ident
you are loading a specific entity from the database into a local app db table. A custom target will be ignored.
- `class-or-factory` : A component that implements IQuery, or a factory for it (if using dynamic queries). This will be combined with `server-property` into a join for the server query. Needed to normalize results.
  class-or-factory can be nil, in which case the resulting server query will not be a join.
- `config` : A map of load configuration parameters.

Config (all optional):
- `target` - An assoc-in path at which to put the result of the Subquery (as an edge (normalized) or value (not normalized)).
  Can also be special targets (multiple-targets, append-to,
  prepend-to, or replace-at). If you are loading by keyword (into root), then this relocates the result (ident or value) after load.
  When loading an entity (by ident), then this option will place additional idents at the target path(s) that point to that entity.
- `initialize` - REMOVED. Use component pre-merge instead.
- `remote` - Optional. Keyword name of the remote that this load should come from.
- `params` - Optional parameters to add to the generated query
- `marker` - ID of marker. Normalizes a load marker into app state so you can see progress.
- `refresh` - A list of things in the UI to refresh. Depends on rendering optimization.
- `parallel` - Send the load out-of-order (immediately) without waiting for other loads in progress.
- `post-mutation` - DEPRECATED. use post-action. A mutation (symbol) to run after the data is merged. Note, if target is supplied be sure your post mutation
should expect the data at the targeted location. The `env` of that mutation will be the env of the load (if available), but will also include `:load-request`.
- `post-mutation-params` - An optional map  that will be passed to the post-mutation when it is called. May only contain raw data, not code!
- `ok-action` - WARNING: OVERRIDES ALL DEFAULT OK BEHAVIOR (post-mutation, merge, clearing load marker)! A lambda that will receive the remote result in a mutation env parameter `(fn [env] ...)`.
- `post-action` - A lambda that will receive the remote result in a mutation env parameter `(fn [env] ...)`. Called after success, like post-mutation,
but as a lambda.
- `error-action` - A lambda that will receive the errant result (bad server status code/body) in a mutation env parameter `(fn [env] ...)`. Like the error-action section
of mutations.
- `fallback` - A mutation (symbol) to run if there is a server/network error. The `env` of the fallback will be like a mutation `env`, and will
include a `:result` key with the real result from the server.
- `update-query` - A optional function that can transform the component query before sending to remote.
    For example, to focus a subquery using update-query:
        {:update-query #(eql/focus-subquery % [:my {:sub [:query]}])}

    Removing properties (like previous :without option):
        {:update-query #(df/elide-query-nodes % #{:my :elisions})}
- `focus` - Focus the query along a path. See eql/focus-subquery.
- `without` - A set of keys to remove (recursively) from the query.
- `abort-id` - TODO. Normally use txn id, which is returned by this function.

Returns a transaction ID, which can be used with abort
sourceraw docstring

load-failed!clj/s

(load-failed! {:keys [app] :as env}
              {:keys [error-action marker fallback] :as params})

The normal internal processng of a load that has failed (error returned true). Triggers the error-action and fallback if defined for the load. If there is a global-error-action defined for the app it is also invoked.

The normal internal processng of a load that has failed (error returned true). Triggers the `error-action` and
`fallback` if defined for the load.  If there is a `global-error-action` defined for the app it is also invoked.
sourceraw docstring

load-fieldclj/s

DEPRECATED. Use load-field!

DEPRECATED. Use `load-field!`
sourceraw docstring

load-field!clj/s

(load-field! component field options)

Load a field of the current component. Runs prim/transact!.

Parameters

  • component: The component (instance, not class). This component MUST have an Ident.
  • field: A field on the component's query that you wish to load.
  • options : A map of load options. See load.

WARNING: If you're using dynamic queries, you won't really know what factory your parent is using, nor can you pass it as a parameter to this function. Therefore, it is not recommended to use load-field from within a component that has a dynamic query unless you can base it on the original static query.

Load a field of the current component. Runs `prim/transact!`.

Parameters
- `component`: The component (**instance**, not class). This component MUST have an Ident.
- `field`: A field on the component's query that you wish to load.
- `options` : A map of load options. See `load`.

WARNING: If you're using dynamic queries, you won't really know what factory your parent is using,
nor can you pass it as a parameter to this function. Therefore, it is not recommended to use load-field from within
a component that has a dynamic query unless you can base it on the original static query.
sourceraw docstring

load-marker?clj/s

(load-marker? x)

Is the given parameter a load marker?

Is the given parameter a load marker?
sourceraw docstring

load-params*clj/s

(load-params* app
              server-property-or-ident
              class-or-factory
              {:keys [target params marker post-mutation post-mutation-params
                      without fallback focus ok-action post-action error-action
                      remote abort-id update-query]
               :or {remote :remote marker false}})

Internal function to validate and process the parameters of load and load-action.

Internal function to validate and process the parameters of `load` and `load-action`.
sourceraw docstring

loading?clj/s

(loading? marker)

Is the given load marker loading?

Is the given load marker loading?
sourceraw docstring

marker-tableclj/s

The name of the table in which fulcro load markers are stored. You must query for this via a link query [df/marker-table '_] in any component that needs to use them (and refresh) during loads.

The name of the table in which fulcro load markers are stored. You must query for this via a link query
`[df/marker-table '_]` in any component that needs to use them (and refresh) during loads.
sourceraw docstring

ready?clj/s

(ready? marker)

Is the given load marker ready for loading?

Is the given load marker ready for loading?
sourceraw docstring

refresh!clj/s

(refresh! component)
(refresh! component load-options)
source

remove-load-marker!clj/s

(remove-load-marker! app marker)

Removes the load marker with the given marker id from the df/marker-table.

Removes the load marker with the given `marker` id from the df/marker-table.
sourceraw docstring

set-load-marker!clj/s

(set-load-marker! app marker status)

Adds a load marker at the given marker id to df/marker-table with the given status.

NOTE: You must query for the marker table in any component that wants to show activity.

Adds a load marker at the given `marker` id to df/marker-table with the given status.

NOTE: You must query for the marker table in any component that wants to show activity.
sourceraw docstring

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

× close