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.

NOTE: This can be redefined on an application. If you change your transaction processing routing, then the built-in version will not work, and this docstring does not apply.

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.

NOTE: This can be redefined on an application. If you change your transaction processing routing, then the built-in
version will not work, and this docstring does not apply.

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

add-render-listener!clj/s

(add-render-listener! app nm listener)

Add (or replace) a render listener named nm. listener is a (fn [app options] ) that will be called after each render.

Add (or replace) a render listener named `nm`. `listener` is a `(fn [app options] )` that will be called
after each render.
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)
(current-state app-or-component)

Get the current value of the application state database. If called without arguments it will attempt to find the app in the dynamically-bound comp/app, which is bound during render.

Get the current value of the application state database. If called without arguments it will attempt to find the app
in the dynamically-bound comp/*app*, which is bound during render.
sourceraw docstring

default-global-eql-transformclj/s

[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.

[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

[{:keys [status-code]}]

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

[{:keys [status-code]}]

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

default-tx!clj/sdeprecated

source

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! core-render! optimized-render!
                    render-root! hydrate-root! unmount-root! submit-transaction!
                    abort-transaction! render-middleware initial-db
                    client-will-mount 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 multiple-roots-renderer (highly recommended), but other options are available in the rendering package. Further customizations are also possible. Most applications will likely be best with the default. Standard Fulcro components are also pure (unless you supply shouldComponentUpdate to change that) to prevent rendering when props have not changed.
  • 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-will-mount - A (fn [app]) that is called after the application is fully initialized, but just before it mounts. This is triggered when you call app/mount!, but after all internals have been properly initialized.
  • :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 [remote 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 - DEPRECATED. This will break things in unexpected ways. Prefer :global-eql-transform.
  • :load-marker-default - A default value to use for load markers. Defaults to false.
  • :core-render! - A (fn [app options]) that is mean to side-effect and render your application. Normally does binding of React-based dynamic vars and calls optimized-render!.
  • :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!.
  • :submit-transaction! - A function to implement how to submit transactions. This allows you to override how transactions are processed in Fulcro. Calls to comp/transact! will come through this algorithm.
  • :abort-transaction! - The function that can abort submitted transactions. Must be provided if you override :submit-transaction!, since the two are related.
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 `multiple-roots-renderer` (highly recommended), but other options are available in the rendering package.
   Further customizations are
   also possible.  Most applications will likely be best with the default. Standard Fulcro components are also pure
   (unless you supply `shouldComponentUpdate` to change that) to prevent rendering when props have not changed.
 * `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-will-mount` - A `(fn [app])` that is called after the application is fully initialized, but just before
 it mounts. This is triggered when you call `app/mount!`, but after all internals have been properly initialized.
 * `: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 [remote 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` - DEPRECATED. This will break things in unexpected ways. Prefer `:global-eql-transform`.
 * `:load-marker-default` - A default value to use for load markers. Defaults to false.
 * `:core-render!` - A `(fn [app options])` that is mean to side-effect and render your application. Normally does
   binding of React-based dynamic vars and calls `optimized-render!`.
 * `: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!`.
 * `:submit-transaction!` - A function to implement how to submit transactions. This allows you to override how transactions
   are processed in Fulcro.  Calls to `comp/transact!` will come through this algorithm.
 * `:abort-transaction!` - The function that can abort submitted transactions. Must be provided if you override
   `:submit-transaction!`, since the two are related.
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

headless-synchronous-appclj/s

(headless-synchronous-app faux-root)
(headless-synchronous-app faux-root options)

Returns a new instance from fulcro-app that is pre-configured to use synchronous transaction processing and no rendering. This is particularly useful when you want to write integration tests around a Fulcro app so that the tests need no async support. The faux-root must be a component (which need have no body).

The returned application will be properly initialized, and will have the initial state declared in faux-component already merged into the app's state (i.e. the returned app is ready for operations).

options can be anything from fulcro-app, but :submit-transaction!, :render-root!, and :optimized-render! are ignored.

Returns a new instance from `fulcro-app` that is pre-configured to use synchronous transaction processing
and no rendering. This is particularly useful when you want to write integration tests around a Fulcro
app so that the tests need no async support. The `faux-root` must be a component (which need have no body).

The returned application will be properly initialized, and will have the initial state declared in `faux-component`
already merged into the app's state (i.e. the returned app is ready for operations).

`options` can be anything from `fulcro-app`, but :submit-transaction!, :render-root!, and
:optimized-render! are ignored.
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

remove-render-listener!clj/s

(remove-render-listener! app nm)

Remove the render listener named nm.

Remove the render listener named `nm`.
sourceraw docstring

render!clj/s

[app] [app 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.
[app]
[app 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.
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

[app] [app options]

Schedule a render on the next animation frame.

[app]
[app options]

Schedule a render on the next animation frame.
sourceraw docstring

set-remote!clj/s

(set-remote! app remote-name remote)

Add/replace a remote on the given app. remote-name is a keyword, and remote is a Fulcro remote (map containing at least transmit!).

This function is generally safe to call at any time. Requests that are in-flight on an old version of the remote will complete on that remote, and any that are queued will be processed by the new one; however, if the old remote supported abort operations then an abort on in-flight requests of the old remote will not work (since you're replaced the remote that the details about that request).

This function changes the content of the application's runtime atom so you do not need to capture the return value, which is the app you passed in.

Add/replace a remote on the given app. `remote-name` is a keyword, and `remote` is a Fulcro remote (map containing
at least `transmit!`).

This function is *generally* safe to call at any time. Requests that are in-flight on an old version of the remote will complete
on that remote, and any that are queued will be processed by the new one; however, if the old remote supported abort
operations then an abort on in-flight requests of the old remote will not work (since you're replaced the remote that the details
about that request).

This function changes the content of the application's runtime atom so you do not need to capture the return value, which
is the app you passed in.
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