Liking cljdoc? Tell your friends :D

fulcro.client


Applicationcljs


clear-queueclj/s

(clear-queue queue)

Needed for mocking in tests. Do not use directly. Use FulcroApplication protocol methods instead.

Needed for mocking in tests. Do not use directly. Use FulcroApplication protocol methods instead.
raw docstring

fulcro-toolsclj/s


FulcroApplicationclj/s≠protocol

mountclj/s

(mount this root-component target-dom-id)

Start/replace the webapp on the given DOM ID or DOM Node.

Start/replace the webapp on the given DOM ID or DOM Node.

abort-request!clj/s

(abort-request! this abort-id)

Abort the given request on all remotes. abort-id is a self-assigned ID for the remote interaction.

Abort the given request on all remotes. abort-id is a self-assigned ID for the remote interaction.

reset-state!clj/s

(reset-state! this new-state)

Replace the entire app state with the given (pre-normalized) state.

Replace the entire app state with the given (pre-normalized) state.

refreshclj/s

(refresh this)

Refresh the UI (force re-render).

Refresh the UI (force re-render).

clear-pending-remote-requests!clj/s

(clear-pending-remote-requests! this remotes)

Remove all pending network requests on the given remote(s). Useful on failures to eliminate cascading failures. Remote can be a keyword, set, or nil. nil means all remotes.

Remove all pending network requests on the given remote(s). Useful on failures to eliminate cascading failures. Remote can be a keyword, set, or nil. `nil` means all remotes.

reset-history!clj/s

(reset-history! this)

Returns the application with history reset to its initial, empty state. Resets application history to its initial, empty state. Suitable for resetting the app for situations such as user log out.

Returns the application with history reset to its initial, empty state. Resets application history to its initial, empty state. Suitable for resetting the app for situations such as user log out.

historyclj/s

(history this)

Return the current UI history of the application, suitable for network transfer

Return the current UI history of the application, suitable for network transfer

reset-app!clj/s

(reset-app! this root-component callback)

Replace the entire app state with the initial app state defined on the root component (includes auto-merging of unions). callback can be nil, a function, or :original (to call original started-callback).

Replace the entire app state with the initial app state defined on the root component (includes auto-merging of unions). callback can be nil, a function, or :original (to call original started-callback).

get-urlcljs

(get-url)

Get the current window location from the browser

Get the current window location from the browser
raw docstring

get-url-paramcljs

(get-url-param param-name)
(get-url-param url param-name)

Get the value of the named parameter from the browser URL (or an explicit one)

Get the value of the named parameter from the browser URL (or an explicit one)
raw docstring

iident?clj/s

DEPRECATED: Now defined in fulcro.client.primitives

DEPRECATED: Now defined in fulcro.client.primitives
raw docstring

iinitial-app-state?clj/s

DEPRECATED: Now defined in fulcro.client.primitives

DEPRECATED: Now defined in fulcro.client.primitives
raw docstring

integrate-identclj/s

DEPRECATED: Now defined in fulcro.client.primitives

DEPRECATED: Now defined in fulcro.client.primitives
raw docstring

integrate-ident!clj/s

DEPRECATED: Now defined in fulcro.client.primitives

DEPRECATED: Now defined in fulcro.client.primitives
raw docstring

merge-alternate-union-elementsclj/s

DEPRECATED: Now defined in fulcro.client.primitives

DEPRECATED: Now defined in fulcro.client.primitives
raw docstring

merge-alternate-union-elements!clj/s

DEPRECATED: Now defined in fulcro.client.primitives

DEPRECATED: Now defined in fulcro.client.primitives
raw docstring

merge-alternate-unionsclj/s

DEPRECATED: Now defined in fulcro.client.primitives

DEPRECATED: Now defined in fulcro.client.primitives
raw docstring

merge-componentclj/s

DEPRECATED: Now defined in fulcro.client.primitives

DEPRECATED: Now defined in fulcro.client.primitives
raw docstring

merge-state!clj/s

(merge-state! app-or-reconciler component object-data & named-params)

See primitives/merge-component!

See primitives/merge-component!
raw docstring

mount*clj/s

(mount* {:keys [mounted? initial-state reconciler-options] :as app}
        root-component
        dom-id-or-node)

mutateclj/s


new-fulcro-clientclj/s

(new-fulcro-client &
                   {:keys [initial-state mutation-merge started-callback
                           networking reconciler-options query-interpreter
                           read-local request-transform network-error-callback
                           migrate transit-handlers shared]
                    :or {initial-state {}
                         read-local (constantly false)
                         started-callback (constantly nil)
                         network-error-callback (constantly nil)
                         migrate nil
                         shared nil}})

Entry point for creating a new fulcro client. Instantiates an Application with default values, unless overridden by the parameters. If you do not supply a networking object, one will be provided that connects to the same server the application was served from, at /api.

If you supply a :request-transform it must be a function:

(fn [{:keys [body headers]}] {:body body' :headers headers'})

it can replace the outgoing EDN of body or headers (returning both as a vector). NOTE: Both of these are clojurescript types. The edn will be encoded with transit, and the headers will be converted to a js map. IMPORTANT: Only supported when using the default built-in single-remote networking.

:initial-state is your applications initial state. If it is an atom, it must be normalized. Fulcro databases always have normalization turned on (for server data merging). If it is not an atom, it will be auto-normalized.

:started-callback is an optional function that will receive the intiailized fulcro application after it is mounted in the DOM, and is useful for triggering initial loads, routing mutations, etc. The reconciler is available under the :reconciler key (and you can access the app state, root node, etc from there.)

:network-error-callback is a function of three arguments, the app state atom, status code, and the error, which will be invoked for every network error (status code >= 400, or no network found). Only works if you choose to use the default built-in networking (ignored if you also specify :networking).

:migrate is optional. It is a (fn [state tid->rid] ... state') that should return a new state where all tempids (the keys of tid->rid) are rewritten to real ids (the values of tid->rid). This defaults to a full recursive algorithm against all data in the app-state, which is correct but possibly slow). Note that tempids will have an tempid data type. See reconciler documentation for further information.

:transit-handlers (optional). A map with keys for :read and :write, which contain maps to be used for the read and write side of transit to extend the supported data types. See make-fulcro-network in network.cljs. Only used when you default to the built-in networking.

:shared (optional). A map of arbitrary values to be shared across all components, accessible to them via (prim/shared this)

:read-local (optional). An read function for the Parser. (fn [env k params] ...). If supplied, it will be called once for each root-level query key. If it returns nil or false for that key then the built-in Fulcro read will handle that branch of the root query. If it returns a map with the shape {:value ...}, then that will be used for the response. This is not recursive. If you begin handling a branch (e.g. a join), you must finish doing so (though if using recursion, you can technically handle just the properties that need your custom handling). At any time you can use prim/db->tree to get raw graph data from the database for a branch. NOTE: it will be allowed to trigger remote reads. This is not recommended, as you will probably have to augment the networking layer to get it to do what you mean. Use load instead. You have been warned. Triggering remote reads is allowed, but discouraged and unsupported.

:query-interpreter (optional). A custom query engine (parser and interpreter) that will be used to satisfy all local client queries from the local state database. Cannot be used with :read-local. It must be a (fn [env query] ) that returns the result for the given query. It will not be given mutations. The env will contain the :state atom, :shared, and :parser. It may also contain the :reconciler.

:networking (optional). An instance of FulcroNetwork that will act as the default remote (named :remote). If you want to support multiple remotes, then this should be a map whose keys are the keyword names of the remotes and whose values are FulcroNetwork instances.

:mutation-merge (optional). A function(fn [state mutation-symbol return-value])` that receives the app state as a map (NOT an atom) and should return the new state as a map. This function is run when network results are being merged, and is called once for each mutation that had a return value on the server. Returning nil from this function is safe, and will be ignored with a console message for debugging. If you need information about the original mutation arguments then you must reflect them back from the server in your return value. By default such values are discarded.

:reconciler-options (optional). A map that will be merged into the reconciler options. Currently it's mostly useful to override things like :root-render and :root-unmount for React Native Apps.

There is currently no way to circumvent the encoding of the body into transit. If you want to talk to other endpoints via alternate protocols you must currently implement that outside of the framework (e.g. global functions/state).

Entry point for creating a new fulcro client. Instantiates an Application with default values, unless
 overridden by the parameters. If you do not supply a networking object, one will be provided that connects to the
 same server the application was served from, at `/api`.

 If you supply a `:request-transform` it must be a function:

 ```
(fn [{:keys [body headers]}] {:body body' :headers headers'})
 ```

 it can replace the outgoing EDN of body or headers (returning both as a vector). NOTE: Both of these are clojurescript types.
 The edn will be encoded with transit, and the headers will be converted to a js map. IMPORTANT: Only supported
 when using the default built-in single-remote networking.

 `:initial-state` is your applications initial state. If it is an atom, it *must* be normalized. Fulcro databases
 always have normalization turned on (for server data merging). If it is not an atom, it will be auto-normalized.

 `:started-callback` is an optional function that will receive the intiailized fulcro application after it is
 mounted in the DOM, and is useful for triggering initial loads, routing mutations, etc. The reconciler is available
 under the `:reconciler` key (and you can access the app state, root node, etc from there.)

 `:network-error-callback` is a function of three arguments, the app state atom, status code, and the error, which will be invoked for
 every network error (status code >= 400, or no network found). Only works if you choose to use the default built-in
 networking (ignored if you also specify :networking).

 `:migrate` is optional. It is a (fn [state tid->rid] ... state') that should return a new state where all tempids
 (the keys of `tid->rid`) are rewritten to real ids (the values of tid->rid). This defaults to a full recursive
 algorithm against all data in the app-state, which is correct but possibly slow).  Note that tempids will have an tempid data type.
 See reconciler documentation for further information.

 `:transit-handlers` (optional). A map with keys for `:read` and `:write`, which contain maps to be used for the read
 and write side of transit to extend the supported data types. See `make-fulcro-network` in network.cljs. Only used
 when you default to the built-in networking.

 `:shared` (optional). A map of arbitrary values to be shared across all components, accessible to them via (prim/shared this)

 `:read-local` (optional). An read function for the Parser. (fn [env k params] ...). If supplied,
 it will be called once for each root-level query key. If it returns `nil` or `false` for that key then the built-in Fulcro read will handle that
 branch of the root query. If it returns a map with the shape `{:value ...}`, then that will be used for the response. This is *not*
 recursive. If you begin handling a *branch* (e.g. a join), you must finish doing so (though if using recursion, you can technically handle just
 the properties that need your custom handling). At any time you can use `prim/db->tree` to get raw graph data from the database for a branch.
 NOTE: *it will be allowed* to trigger remote reads. This is not recommended, as you will probably have to augment the networking layer to
 get it to do what you mean. Use `load` instead. You have been warned. Triggering remote reads is allowed, but discouraged and unsupported.

 `:query-interpreter` (optional). A custom query engine (parser and interpreter) that will be used to satisfy all
 local client queries from the local state database. Cannot be used with `:read-local`.
 It must be a `(fn [env query] )` that returns the result for the given query. It will not be given mutations.
 The `env` will contain the `:state` atom, `:shared`, and `:parser`. It may also contain the `:reconciler`.

 `:networking` (optional). An instance of FulcroNetwork that will act as the default remote (named :remote). If
 you want to support multiple remotes, then this should be a map whose keys are the keyword names of the remotes
 and whose values are FulcroNetwork instances.

 `:mutation-merge (optional). A function `(fn [state mutation-symbol return-value])` that receives the app state as a
 map (NOT an atom) and should return the new state as a map. This function is run when network results are being merged,
 and is called once for each mutation that had a return value on the server. Returning nil from this function is safe, and will be ignored
 with a console message for debugging. If you need information about the original mutation arguments then you must reflect
 them back from the server in your return value. By default such values are discarded.
 
 `:reconciler-options (optional). A map that will be merged into the reconciler options. Currently it's mostly
 useful to override things like :root-render and :root-unmount for React Native Apps.`

 There is currently no way to circumvent the encoding of the body into transit. If you want to talk to other endpoints
 via alternate protocols you must currently implement that outside of the framework (e.g. global functions/state).
 
raw docstring

new-fulcro-test-clientclj/s

(new-fulcro-test-client &
                        {:keys [initial-state started-callback
                                reconciler-options]
                         :or {initial-state {} started-callback nil}})

Create a test client that has no networking. Useful for UI testing with a real Fulcro app container.

Create a test client that has no networking. Useful for UI testing with a real Fulcro app container.
raw docstring

refresh*clj/s

(refresh* {:keys [reconciler] :as app} root target)

register-toolclj/s

(register-tool {:keys [:fulcro.client/tool-id] :as tool-registry})

Register a debug tool. When an app starts, the debug tool can have several hooks that are notified:

::tool-id some identifier to place the tool into the tool map ::tx-listen is a (fn [tx info] ...) that will be called on every transact! of the app. Return value is ignored. ::network-wrapper is (fn [network-map] network-map') that will be given the networking config BEFORE it is initialized. You can wrap them, but you MUST return a compatible map out or you'll disable networking. ::component-lifecycle is (fn [component evt]) that is called with evt of :mounted and :unmounted to tell you when the given component mounts/unmounts. ::instrument-wrapper is a (fn [instrument] instrument') that allows you to wrap your own instrumentation (for rendering) around any existing (which may be nil) ::app-started (fn [app] ...) that will be called once the app is mounted, just like started-callback. Return value ignored.

Register a debug tool. When an app starts, the debug tool can have several hooks that are notified:

::tool-id some identifier to place the tool into the tool map
::tx-listen is a (fn [tx info] ...) that will be called on every `transact!` of the app. Return value is ignored.
::network-wrapper is (fn [network-map] network-map') that will be given the networking config BEFORE it is initialized. You can wrap
them, but you MUST return a compatible map out or you'll disable networking.
::component-lifecycle is (fn [component evt]) that is called with evt of :mounted and :unmounted to tell you when the given component mounts/unmounts.
::instrument-wrapper is a (fn [instrument] instrument') that allows you to wrap your own instrumentation (for rendering) around any existing (which may be nil)
::app-started (fn [app] ...) that will be called once the app is mounted, just like started-callback. Return value ignored.
raw docstring

reset-history-implclj/s

(reset-history-impl {:keys [reconciler]})

Needed for mocking in tests. Use FulcroApplication protocol methods instead.

Needed for mocking in tests. Use FulcroApplication protocol methods instead.
raw docstring

uri-paramscljs

(uri-params)
(uri-params url)

Get the current URI parameters from the browser url or one you supply

Get the current URI parameters from the browser url or one you supply
raw docstring

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

× close