Liking cljdoc? Tell your friends :D

com.fulcrologic.fulcro.application


app-rootclj/s

(app-root app)

Returns the current app root, if mounted.

Returns the current app root, if mounted.
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 value of the application state database at the current time.

Get the value of the application state database at the current time.
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
  • The form-state configuration join

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`
- The form-state configuration join

Takes an AST and returns the modified AST.
sourceraw docstring

default-remote-error?clj/s

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

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 any->reconciler 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 any->reconciler 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! render-middleware initial-db client-did-mount
                    remote-error? remotes query-transform-default
                    load-marker-default load-mutation shared 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. - :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.

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.
    - `: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`.
  
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

mount!clj/s

(mount! app root node)
(mount! app root node {:keys [initialize-state? 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:

  • :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:

- `: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

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

tick!clj/s

(tick! app)

Move the basis-t forward one tick. For internal use and internal algorithms.

Move the basis-t forward one tick. For internal use and internal algorithms.
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