Liking cljdoc? Tell your friends :D

com.fulcrologic.fulcro.application


abort!clj/s

(abort! app-ish abort-id)

Attempt to abort the send queue entries with the given abort ID. Will notify any aborted operations (e.g. result-handler will be invoked, remote-error? will be used to decide if you consider that an error, etc.). The result map from an abort will include {::txn/aborted? true}, but will not include :status-code or :body.

This function affects both started and non-started items in the send queues, but will not affect submissions that have not yet made it to the network processing layer (things still in top-level transaction submission queue).

So the sequence of calls:

(comp/transact! this `[(f)] {:abort-id :a})
(app/abort! this :a)

will cancel anything active with abort id :a, but since you've held the thread the entire time the submission of mutation (f) is still on the submission queue and will not be aborted.

  • app-ish: Anything that can be coerced to an app with comp/any->app.
  • abort-id: The abort ID of the operations to be aborted.
Attempt to abort the send queue entries with the given abort ID.  Will notify any aborted operations (e.g. result-handler
will be invoked, remote-error? will be used to decide if you consider that an error, etc.).
The result map from an abort will include `{::txn/aborted? true}`, but will not include `:status-code` or `:body`.

This function affects both started and non-started items in the send queues, but will not affect submissions that have not yet
made it to the network processing layer (things still in top-level transaction submission queue).

So the sequence of calls:

```
(comp/transact! this `[(f)] {:abort-id :a})
(app/abort! this :a)
```

will cancel anything active with abort id `:a`, but since you've held the thread the entire time the submission of
mutation `(f)` is still on the submission queue and will not be aborted.

- `app-ish`: Anything that can be coerced to an app with comp/any->app.
- `abort-id`: The abort ID of the operations to be aborted.
sourceraw docstring

app-rootclj/s

(app-root app)

Returns the current app root, if mounted. WARNING: The :client-did-mount in the app settings will not see a value from this function due to the async nature of React. If you need to call this at app startup use the :componentDidMount lifecycle method of your root component (at which point this will return the same thing as this in that method).

Returns the current app root, if mounted. WARNING: The `:client-did-mount` in the app settings will *not* see a value
from this function due to the async nature of React. If you need to call this at app startup use the `:componentDidMount`
lifecycle method of your root component (at which point this will return the same thing as `this` in that method).
sourceraw docstring

basis-tclj/s

(basis-t app)

Return the current basis time of the app.

Return the current basis time of the app.
sourceraw docstring

current-stateclj/s

(current-state app-or-component)

Get the current value of the application state database.

Get the current value of the application state database.
sourceraw docstring

default-global-eql-transformclj/s

(default-global-eql-transform ast)

The default query transform function. It makes sure the following items on a component query are never sent to the server:

  • Props whose namespace is ui
  • Any prop or join that is namespaced to com.fulcrologic.fulcro*
  • Any ident (as a prop or join) whose table name is namespaced ui or com.fulcrologic.fulcro*

Takes an AST and returns the modified AST.

The default query transform function.  It makes sure the following items on a component query
are never sent to the server:

- Props whose namespace is `ui`
- Any prop or join that is namespaced to com.fulcrologic.fulcro*
- Any ident (as a prop or join) whose table name is namespaced ui or com.fulcrologic.fulcro*

Takes an AST and returns the modified AST.
sourceraw docstring

default-remote-error?clj/s

(default-remote-error? {:keys [status-code]})

Default detection of network errors. Returns true if the status-code of the given result map is not 200.

Default detection of network errors. Returns true if the status-code of the given result
map is not 200.
sourceraw docstring

default-tx!clj/s

(default-tx! app tx)
(default-tx! {:keys [:com.fulcrologic.fulcro.application/runtime-atom] :as app}
             tx
             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

force-root-render!clj/s

(force-root-render! app-ish)

Force a re-render of the root. Runs a root query, disables shouldComponentUpdate, and renders the root component. This effectively forces React to do a full VDOM diff. Useful for things like UI refresh on hot code reload and changing locales where there are no real data changes, but the UI still needs to refresh.

Argument can be anything that comp/any->app accepts.

WARNING: This disables all Fulcro rendering optimizations, so it is much slower than other ways of refreshing the app. Use schedule-render! to request a normal optimized render.

Force a re-render of the root. Runs a root query, disables shouldComponentUpdate, and renders the root component.
This effectively forces React to do a full VDOM diff. Useful for things like UI refresh on hot code reload and
changing locales where there are no real data changes, but the UI still needs to refresh.

Argument can be anything that comp/any->app accepts.

WARNING: This disables all Fulcro rendering optimizations, so it is much slower than other ways of refreshing the app.
Use `schedule-render!` to request a normal optimized render.
sourceraw docstring

fulcro-appclj/s

(fulcro-app)
(fulcro-app {:keys [props-middleware global-eql-transform global-error-action
                    default-result-action! optimized-render! render-root!
                    hydrate-root! unmount-root! render-middleware initial-db
                    client-did-mount remote-error? remotes
                    query-transform-default load-marker-default load-mutation
                    root-class shared external-config shared-fn]
             :as options})

Create a new Fulcro application.

options: A map of initial options

  • :initial-db a map containing a normalized Fulcro app db. Normally Fulcro will populate app state with your component tree's initial state. Use mount! options to toggle the initial state pull from root.
  • :optimized-render! - A function that can analyze the state of the application and optimally refresh the screen. Defaults to ident-optimized-render/render!, but can also be set to keyframe-render/render!. Further customizations are also possible. Most applications will likely be best with the default (which analyzes changes by ident and targets refreshes), but applications with a lot of on-screen components may find the keyframe renderer to be faster. Both get added benefits from Fulcro's default shouldComponentUpdate, which will prevent rendering when there are no real changes.
  • default-result-action! - A (fn [env]) that will be used in your mutations defined with defmutation as the default :result-action when none is supplied. Normally defaults to a function that supports mutation joins, targeting, and ok/error actions. WARNING: Overriding this is for advanced users and can break important functionality. The default is value for this option is com.fulcrologic.fulcro.mutations/default-result-action!, which could be used as an element of your own custom implementation.
  • :global-eql-transform - A (fn [AST] new-AST) that will be asked to rewrite the AST of all transactions just before they are placed on the network layer.
  • :client-did-mount - A (fn [app]) that is called when the application mounts the first time. WARNING: Due to the async nature of js and React this function is not guaranteed to be called after the application is completely on the DOM. If you need that guarantee then consider using :componentDidMount on your application's root component.
  • :remotes - A map from remote name to a remote handler, which is defined as a map that contains at least a :transmit! key whose value is a (fn [send-node]). See networking.http-remote.
  • :shared - A (static) map of data that should be visible in all components through comp/shared.
  • :shared-fn - A function on root props that can select/augment shared whenever a forced root render or explicit call to app/update-shared! happens.
  • :props-middleware - A function that can add data to the 4th (optional) argument of defsc. Useful for allowing users to quickly destructure extra data created by component extensions. See the fulcro-garden-css project on github for an example usage.
  • :render-middleware - A (fn [this real-render]). If supplied it will be called for every Fulcro component render, and must call (and return the result of) real-render. This can be used to wrap the real render function in order to do things like measure performance, set dynamic vars, or augment the UI in arbitrary ways. this is the component being rendered.
  • :remote-error? - A (fn [result] boolean). It can examine the network result and should only return true when the result is an error. The result will contain both a :body and :status-code when using the normal remotes. The default version of this returns true if the status code isn't 200.
  • :global-error-action - A (fn [env] ...) that is run on any remote error (as defined by remote-error?).
  • :load-mutation - A symbol. Defines which mutation to use as an implementation of low-level load operations. See Developer's Guide
  • :query-transform-default - A (fn [query] query'). Defaults to a function that strips :ui/... keywords and form state config joins from load queries.
  • :load-marker-default - A default value to use for load markers. Defaults to false.
  • :render-root! - The function to call in order to render the root of your application. Defaults to js/ReactDOM.render.
  • :hydrate-root! - The function to call in order to hydrate the root of your application. Defaults to js/ReactDOM.hydrate.
  • :unmount-root! - The function to call in order to unmount the root of your application. Defaults to js/ReactDOM.unmountComponentAtNode.
  • :root-class - The component class that will be the root. This can be specified just with mount!, but giving it here allows you to do a number of tasks against the app before it is actually mounted. You can also use app/set-root!.
Create a new Fulcro application.

`options`: A map of initial options

 * `:initial-db` a *map* containing a *normalized* Fulcro app db.  Normally Fulcro will populate app state with
   your component tree's initial state.  Use `mount!` options to toggle the initial state pull from root.
 * `:optimized-render!` - A function that can analyze the state of the application and optimally refresh the screen.
   Defaults to `ident-optimized-render/render!`, but can also be set to `keyframe-render/render!`.  Further customizations are
   also possible.  Most applications will likely be best with the default (which analyzes changes by ident and targets
   refreshes), but applications with a lot of on-screen components may find the keyframe renderer to be faster. Both
   get added benefits from Fulcro's default `shouldComponentUpdate`, which will prevent rendering when there are no real
   changes.
 * `default-result-action!` - A `(fn [env])` that will be used in your mutations defined with `defmutation` as the
   default `:result-action` when none is supplied. Normally defaults to a function that supports mutation joins, targeting,
   and ok/error actions. WARNING: Overriding this is for advanced users and can break important functionality. The
   default is value for this option is `com.fulcrologic.fulcro.mutations/default-result-action!`, which could be used
   as an element of your own custom implementation.
 * `:global-eql-transform` - A `(fn [AST] new-AST)` that will be asked to rewrite the AST of all transactions just
   before they are placed on the network layer.
 * `:client-did-mount` - A `(fn [app])` that is called when the application mounts the first time. WARNING: Due to
   the async nature of js and React this function is not guaranteed to be called after the application is
   completely on the DOM.  If you need that guarantee then consider using `:componentDidMount` on your application's
   root component.
 * `:remotes` - A map from remote name to a remote handler, which is defined as a map that contains at least
   a `:transmit!` key whose value is a `(fn [send-node])`. See `networking.http-remote`.
 * `:shared` - A (static) map of data that should be visible in all components through `comp/shared`.
 * `:shared-fn` - A function on root props that can select/augment shared whenever a forced root render
   or explicit call to `app/update-shared!` happens.
 * `:props-middleware` - A function that can add data to the 4th (optional) argument of
   `defsc`.  Useful for allowing users to quickly destructure extra data created by
   component extensions. See the fulcro-garden-css project on github for an example usage.
 * `:render-middleware` - A `(fn [this real-render])`. If supplied it will be called for every Fulcro component
   render, and *must* call (and return the result of) `real-render`.  This can be used to wrap the real render
   function in order to do things like measure performance, set dynamic vars, or augment the UI in arbitrary ways.
   `this` is the component being rendered.
 * `:remote-error?` - A `(fn [result] boolean)`. It can examine the network result and should only return
   true when the result is an error. The `result` will contain both a `:body` and `:status-code` when using
   the normal remotes.  The default version of this returns true if the status code isn't 200.
 * `:global-error-action` - A `(fn [env] ...)` that is run on any remote error (as defined by `remote-error?`).
 * `:load-mutation` - A symbol. Defines which mutation to use as an implementation of low-level load operations. See
   Developer's Guide
 * `:query-transform-default` - A `(fn [query] query')`. Defaults to a function that strips `:ui/...` keywords and
   form state config joins from load queries.
 * `:load-marker-default` - A default value to use for load markers. Defaults to false.
 * `:render-root!` - The function to call in order to render the root of your application. Defaults
   to `js/ReactDOM.render`.
 * `:hydrate-root!` - The function to call in order to hydrate the root of your application. Defaults
   to `js/ReactDOM.hydrate`.
 * `:unmount-root!` - The function to call in order to unmount the root of your application. Defaults
   to `js/ReactDOM.unmountComponentAtNode`.
 * `:root-class` - The component class that will be the root. This can be specified just with `mount!`, but
 giving it here allows you to do a number of tasks against the app before it is actually mounted. You can also use `app/set-root!`.
sourceraw docstring

fulcro-app?clj/s

(fulcro-app? x)

Returns true if the given x is a Fulcro application.

Returns true if the given `x` is a Fulcro application.
sourceraw docstring

initialize-state!clj/s

(initialize-state! app root)

Initialize the app state using root component's app state. This will deep merge against any data that is already in the state atom of the app. Can be called before mount!, in which case you should tell mount not to (re) initialize state.

Initialize the app state using `root` component's app state. This will deep merge against any data that is already
in the state atom of the app. Can be called before `mount!`, in which case you should tell mount not to (re) initialize
state.
sourceraw docstring

mount!clj/s

(mount! app root node)
(mount! app
        root
        node
        {:keys [initialize-state? hydrate? disable-client-did-mount?]})

Mount the app. If called on an already-mounted app this will have the effect of re-installing the root node so that hot code reload will refresh the UI (useful for development).

  • app The Fulcro app
  • root The Root UI component
  • node The (string) ID or DOM node on which to mount.
  • options An optional map with additional mount options.

options can include:

  • :disable-client-did-mount? (default false) - When false a true mount (as opposed to redundant) call of this function will invoke the application's :client-did-mount callback.
  • :initialize-state? (default true) - If NOT mounted already: Pulls the initial state tree from root component, normalizes it, and installs it as the application's state. If there was data supplied as an initial-db, then this new initial state will be merged with that initial-db.
  • :hydrate? (default false) - Indicates that the DOM will already contain content from the server that should be attached instead of overwritten. See ReactDOM.hydrate.
Mount the app.  If called on an already-mounted app this will have the effect of re-installing the root node so that
hot code reload will refresh the UI (useful for development).

- `app`  The Fulcro app
- `root`  The Root UI component
- `node` The (string) ID or DOM node on which to mount.
- `options` An optional map with additional mount options.


`options` can include:

- `:disable-client-did-mount?` (default false) - When false a true mount (as opposed to redundant) call of this function will
invoke the application's `:client-did-mount` callback.
- `:initialize-state?` (default true) - If NOT mounted already: Pulls the initial state tree from root component,
normalizes it, and installs it as the application's state.  If there was data supplied as an initial-db, then this
new initial state will be *merged* with that initial-db.
- `:hydrate?` (default false) - Indicates that the DOM will already contain content from the
  server that should be attached instead of overwritten. See ReactDOM.hydrate.
sourceraw docstring

mounted?clj/s

(mounted? {:keys [:com.fulcrologic.fulcro.application/runtime-atom]})

Is the given app currently mounted on the DOM?

Is the given app currently mounted on the DOM?
sourceraw docstring

remount!clj/s

(remount! app new-node)
(remount! app new-node options)

Remount the currently-mounted root onto a new DOM node. This is a convenience for umount/mount. The options map is sent to mount!, and defaults to:

{:initialize-state? false
 :hydrate? false
 :disable-client-did-mount? true}
Remount the currently-mounted root onto a new DOM node. This is a convenience for umount/mount.
The options map is sent to `mount!`, and defaults to:

```
{:initialize-state? false
 :hydrate? false
 :disable-client-did-mount? true}
```
sourceraw docstring

render!clj/s

(render! app)
(render! app {:keys [force-root?] :as options})

Render the application immediately. Prefer schedule-render!, which will ensure no more than 60fps.

This is the central processing for render and cannot be overridden. schedule-render! will always invoke this function. The optimized render is called by this function, which does extra bookkeeping and other supporting features common to all rendering.

Options include:

  • force-root?: boolean. When true disables all optimizations and forces a full root re-render.
  • anything your selected rendering optization system allows. Shared props are updated via shared-fn only on force-root? and when (shallow) root props change.
Render the application immediately.  Prefer `schedule-render!`, which will ensure no more than 60fps.

This is the central processing for render and cannot be overridden. `schedule-render!` will always invoke
this function.  The optimized render is called by this function, which does extra bookkeeping and
other supporting features common to all rendering.

Options include:
- `force-root?`: boolean.  When true disables all optimizations and forces a full root re-render.
- anything your selected rendering optization system allows.  Shared props are updated via `shared-fn`
only on `force-root?` and when (shallow) root props change.
sourceraw docstring

root-classclj/s

(root-class app)

Returns the current app root class, if mounted.

Returns the current app root class, if mounted.
sourceraw docstring

root-props-changed?clj/s

(root-props-changed? app)

Returns true if the props queries directly by the root component of the app (if mounted) have changed since the last render. This is a shallow analysis such that, for example, a join from root (in a normalized db) will be checked as a difference of idents that the root prop points to. This can be used for determining if things like shared-fn need to be re-run, and if it would simply be quicker to keyframe render the entire tree.

This is a naivé algorithm that is essentially select-keys on the root props. It does not interpret the query in any way.

Returns true if the props queries directly by the root component of the app (if mounted) have changed since the last
render.  This is a shallow analysis such that, for example, a join from root (in a normalized db) will be checked as a difference
of idents that the root prop points to.  This can be used for determining if things like shared-fn need to be re-run,
and if it would simply be quicker to keyframe render the entire tree.

This is a naivé algorithm that is essentially `select-keys` on the root props. It does not interpret the query in
any way.
sourceraw docstring

schedule-render!clj/s

(schedule-render! app)
(schedule-render! app options)

Schedule a render on the next animation frame.

Schedule a render on the next animation frame.
sourceraw docstring

set-root!clj/s

(set-root! app root {:keys [initialize-state?]})

Set a root class to use on the app. Doing so allows much of the API to work before mounting the app.

Set a root class to use on the app. Doing so allows much of the API to work before mounting the app.
sourceraw docstring

tick!clj/s

(tick! app)

Move the basis-t forward one tick. For internal use in internal algorithms. Fulcro uses this to add metadata to props so it can detect the newer of two version of props.

Move the basis-t forward one tick. For internal use in internal algorithms. Fulcro
uses this to add metadata to props so it can detect the newer of two version of props.
sourceraw docstring

unmount!clj/s

(unmount! app)

Removes the app from its mount point. If you want to re-mount a running app, then you should pass :initialize-state? false when you re-mount it and also consider the :disable-client-did-mount? option.

Removes the app from its mount point. If you want to re-mount a running app, then you should pass
`:initialize-state? false` when you re-mount it and also consider the `:disable-client-did-mount?` option.
sourceraw docstring

update-shared!clj/s

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

Force shared props to be recalculated. This updates the shared props on the app, and future renders will see the updated values. This is a no-op if no shared-fn is defined on the app. If you're using React 16+ consider using Context instead of shared.

Force shared props to be recalculated. This updates the shared props on the app, and future renders will see the
updated values. This is a no-op if no shared-fn is defined on the app. If you're using React 16+ consider using
Context instead of shared.
sourceraw docstring

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

× close