Liking cljdoc? Tell your friends :D

fulcro.client.network


active?clj/s

(active? network-markers)
(active? network-markers remote)

Returns true if any of networks (obtained by querying [::net/status '_]) are active. If passed a remote as a second argument if returns whether or not that particular remote is active.

Returns true if any of networks (obtained by querying `[::net/status '_]`) are active.  If passed a remote
as a second argument if returns whether or not that particular remote is active.
raw docstring

cleanup-routine*clj/s

(cleanup-routine* abort-id active-requests xhrio)

clear-request*clj/s

(clear-request* active-requests id xhrio)

error-routine*clj/s

(error-routine* get-response ok-routine progress-routine raw-error-handler)

Returns a (fn [xhrio-evt]) that pulls the progress and reports it to the progress routine and the raw error handler.

Returns a (fn [xhrio-evt]) that pulls the progress and reports it to the progress routine and the raw
error handler.
raw docstring

extract-responseclj/s

(extract-response tx request xhrio)

Generate a response map from the status of the given xhrio object, which could be in a complete or error state.

Generate a response map from the status of the given xhrio object, which could be in a complete or error state.
raw docstring

fulcro-http-remoteclj/s

(fulcro-http-remote {:keys [url request-middleware response-middleware serial?]
                     :or {url "/api"
                          response-middleware (wrap-fulcro-response)
                          request-middleware (wrap-fulcro-request)}
                     :as options})

Create a remote that (by default) communicates with the given url.

The request middleware is a (fn [request] modified-request). The request will have :url, :body, :method, and :headers. The request middleware defaults to wrap-fulcro-request (which encodes the request in transit+json). The result of this middleware chain on the outgoing request becomes the real outgoing request. It is allowed to modify the url. If the the request middleware returns a corrupt request or throws an exception then the remote code will immediately abort the request. The return value of the middleware will be used to generate a request to :url, with :method (e.g. :post), and the given headers. The body will be sent as-is without further translation.

response-middleware is a function that returns a function (fn [response] mod-response) and defaults to wrap-fulcro-response which decodes the raw response and transforms it back to a response that Fulcro can merge. The response will be a map containing the :transaction, which is the original Fulcro EDN request; :outgoing-request which is the exact request sent on the network; :body, which is the raw data of the response. Additionally, there will be one or more of the following to indicate low-level details of the result: :status-code, :status-text, :error-code (one of :none, :exception, :http-error, :abort, or :timeout), and :error-text. Middleware is allowed to morph any of this to suit its needs.

serial? - A boolean (default true). Should requests to this remote be queued sequentially (false means they will hit the network as submitted, true means the prior one has to complete (by default) before the next starts). Loads can be made parallel with a load option, so you should typically not override this option.

A result with a 200 status code will result in a merge using the resulting response's :transaction as the query, and the :body as the EDN to merge. If the status code is anything else then the details of the response will be used when triggering the built-in error handling (e.g. fallbacks, global error handler, etc.).

Create a remote that (by default) communicates with the given url.

The request middleware is a `(fn [request] modified-request)`. The `request` will have `:url`, `:body`, `:method`, and `:headers`. The
request middleware defaults to `wrap-fulcro-request` (which encodes the request in transit+json). The result of this
middleware chain on the outgoing request becomes the real outgoing request. It is allowed to modify the `url`.
If the the request middleware returns a corrupt request or throws an exception then the remote code
will immediately abort the request. The return value of the middleware will be used to generate a request to `:url`,
with `:method` (e.g. :post), and the given headers. The body will be sent as-is without further translation.

`response-middleware` is a function that returns a function `(fn [response] mod-response)` and
defaults to `wrap-fulcro-response` which decodes the raw response and transforms it back to a response that Fulcro can merge.
The response will be a map containing the `:transaction`, which is the
original Fulcro EDN request; `:outgoing-request` which is the exact request sent on the network; `:body`, which
is the raw data of the response. Additionally, there will be one or more of the following to indicate low-level
details of the result: `:status-code`, `:status-text`, `:error-code` (one of :none, :exception, :http-error, :abort, or :timeout),
and `:error-text`.  Middleware is allowed to morph any of this to suit its needs.

`serial?` - A boolean (default true). Should requests to this remote be queued sequentially (false means they will hit the network
as submitted, true means the prior one has to complete (by default) before the next starts).  Loads can be made parallel
with a load option, so you should typically not override this option.

A result with a 200 status code will result in a merge using the resulting response's `:transaction` as the query,
and the `:body` as the EDN to merge. If the status code is anything else then the details of the response will be
used when triggering the built-in error handling (e.g. fallbacks, global error handler, etc.).
raw docstring

FulcroHTTPRemotecljs


FulcroNetworkclj/s≠protocol

sendclj/s

(send this edn done-callback error-callback)

DEPRECATED. Send EDN. Calls either the done or error callback when the send is done. You must call one of those only once. Implement ProgressiveTransfer if you want to do progress updates during network transmission.

DEPRECATED. Send EDN. Calls either the done or error callback when the send is done. You must call one of those only once.
Implement ProgressiveTransfer if you want to do progress updates during network transmission.

startclj/s

(start this)

Starts the network.

Starts the network.

FulcroRemoteIclj/s≠protocol

abortclj/s

(abort this abort-id)

Cancel the network activity for the given request id, supplied during submission.

Cancel the network activity for the given request id, supplied during submission.

transmitclj/s

(transmit this request)

Send the given request, which will contain:

  • :fulcro.client.network/edn : The actual API tx to send.
  • :fulcro.client.network/ok-handler : complete-fn
  • :fulcro.client.network/error-handler : error-fn
  • :fulcro.client.network/progress-handler : update-fn

It may also optionally include:

  • :fulcro.client.network/abort-id : An ID to remember the network request by, to enable user-level API abort

When you implement this protocol, you MUST call the ok-handler or error-handler exactly once. You may call the progress-handler any number of times (including none).

ok-hander - A (fn [{:keys [transaction body]}] ...) that will merge the edn result using the given transaction (query) error-handler - A (fn [{:keys [body]}] ...) that will report an error to Fulcro. The body is EDN that will be placed into the state as the error. progress-handler - A (fn [progress] ...) that will run all registered progress mutations, and will include progress in the parameters of each progress mutation.

Send the given `request`, which will contain:
- `:fulcro.client.network/edn` : The actual API tx to send.
- `:fulcro.client.network/ok-handler` : complete-fn
- `:fulcro.client.network/error-handler` : error-fn
- `:fulcro.client.network/progress-handler` : update-fn

It may also optionally include:
- `:fulcro.client.network/abort-id` : An ID to remember the network request by, to enable user-level API abort

When you implement this protocol, you MUST call the `ok-handler` or `error-handler` exactly once. You *may*
call the `progress-handler` any number of times (including none).

ok-hander - A (fn [{:keys [transaction body]}] ...) that will merge the edn result using the given transaction (query)
error-handler - A (fn [{:keys [body]}] ...) that will report an error to Fulcro. The body is EDN that will be placed into the state as the error.
progress-handler - A (fn [progress] ...) that will run all registered progress mutations, and will include `progress` in the parameters of each progress mutation.

IXhrIOCallbacksclj/s≠protocol

response-okclj/s

(response-ok this xhrio ok-cb)

Called by XhrIo on OK

Called by XhrIo on OK

response-errorclj/s

(response-error this xhrio err-cb)

Called by XhrIo on ERROR

Called by XhrIo on ERROR

make-fulcro-networkclj/s

(make-fulcro-network url
                     &
                     {:keys [request-transform global-error-callback
                             transit-handlers]})

DERECATED: Use fulcro-http-remote instead.

Build a Fulcro Network object using the default implementation.

Features:

  • :url is the target URL suffix (URI) on the server for network requests. defaults to /api.
  • :request-transform is a (fn [{:keys [body headers] :as req}] req') to transform arbitrary requests (e.g. to add things like auth headers)
  • :global-error-callback is a global error callback (fn [app-state-map status-code error] ) that is notified when a 400+ status code or hard network error occurs
  • transit-handlers is a map of transit handlers to install on the reader, such as

{ :read { "thing" (fn [wire-value] (convert wire-value))) } :write { Thing (ThingHandler.) } }

where:

(defrecord Thing [foo])

(deftype ThingHandler [] Object (tag [_ _] "thing") (rep [_ thing] (make-raw thing)) (stringRep [_ _] nil)))

DERECATED: Use `fulcro-http-remote` instead.

Build a Fulcro Network object using the default implementation.

Features:

- `:url` is the target URL suffix (URI) on the server for network requests. defaults to /api.
- `:request-transform` is a (fn [{:keys [body headers] :as req}] req') to transform arbitrary requests (e.g. to add things like auth headers)
- `:global-error-callback` is a global error callback (fn [app-state-map status-code error] ) that is notified when a 400+ status code or hard network error occurs
- `transit-handlers` is a map of transit handlers to install on the reader, such as

 `{ :read { "thing" (fn [wire-value] (convert wire-value))) }
    :write { Thing (ThingHandler.) } }`

 where:

 (defrecord Thing [foo])

 (deftype ThingHandler []
   Object
   (tag [_ _] "thing")
   (rep [_ thing] (make-raw thing))
   (stringRep [_ _] nil)))
raw docstring

make-xhriocljs

(make-xhrio)

mock-networkclj/s

(mock-network)

MockNetworkcljs


Networkcljs


NetworkBehaviorclj/s≠protocol

serialize-requests?clj/s

(serialize-requests? this)

Returns true if the network is configured to desire one request at a time.

Returns true if the network is configured to desire one request at a time.

ok-routine*clj/s

(ok-routine* progress-routine get-response-fn raw-ok-handler error-routine)

Returns a (fn [evt] ) that pulls the response, runs it through middleware, and reports the appropriate results to the raw-ok-handler, and progress-routine. If the middleware fails, it will instaed report to the error-routine (which in turn will report to the raw error handler)

Returns a (fn [evt] ) that pulls the response, runs it through middleware, and reports
the appropriate results to the raw-ok-handler, and progress-routine. If the middleware fails,
it will instaed report to the error-routine (which in turn will report to the raw error handler)
raw docstring

parse-responsecljs

(parse-response xhr-io)
(parse-response xhr-io read-handlers)

DEPRECATED. An XhrIo-specific implementation method for interpreting the server response.

DEPRECATED. An XhrIo-specific implementation method for interpreting the server response.
raw docstring

progress%cljs

(progress% progress)
(progress% progress phase)

Takes a map containing :fulcro.client.network/progress (the params map from a progress report mutation) and returns a number between 0 and 100. phase can be :overall, :sending, or :receiving. When set to :overall then the send phase will count for progress points between 0 and 49, and receiving phase will account for 50 to 100. When set to :sending or :receiving the entire range will count for that phase only (i.e. once sending is complete this function would return 100 throughout the receiving phase.)

If total is unknown, then this function returns 0.

Takes a map containing :fulcro.client.network/progress (the params map from a progress report mutation)
and returns a number between 0 and 100. `phase` can be `:overall`, `:sending`, or `:receiving`. When
set to `:overall` then the send phase will count for progress points between 0 and 49, and receiving phase
will account for 50 to 100. When set to :sending or :receiving the entire range will count for that phase only
(i.e. once sending is complete this function would return 100 throughout the receiving phase.)

If total is unknown, then this function returns 0.
raw docstring

progress-routine*clj/s

(progress-routine* get-response-fn raw-update-fn)

Return a (fn [phase progress-event]) that calls the raw update function with progress and response data merged together as a response.

Return a (fn [phase progress-event]) that calls the raw update function with progress and response data merged
together as a response.
raw docstring

ProgressiveTransferclj/s≠protocol

updating-sendclj/s

(updating-send this edn done-callback error-callback update-callback)

DEPRECATED. Send EDN. The update-callback will merge the state given to it. The done-callback will merge the state given to it, and indicates completion. See fulcro.client.ui.file-upload/FileUploadNetwork for an example.

DEPRECATED. Send EDN. The update-callback will merge the state
given to it. The done-callback will merge the state given to it, and indicates completion. See
`fulcro.client.ui.file-upload/FileUploadNetwork` for an example.

response-extractor*clj/s

(response-extractor* response-middleware edn real-request xhrio)

was-network-error?clj/s

(was-network-error? {:keys [status-code error]})

Returns true if the given response looks like a low-level network error.

Returns true if the given response looks like a low-level network error.
raw docstring

wrap-csrf-tokenclj/s

(wrap-csrf-token csrf-token)
(wrap-csrf-token handler csrf-token)

Client remote request middleware. This middleware can be added to add an X-CSRF-Token header to the request.

Client remote request middleware. This middleware can be added to add an X-CSRF-Token header to the request.
raw docstring

wrap-fulcro-requestclj/s

(wrap-fulcro-request)
(wrap-fulcro-request handler)
(wrap-fulcro-request handler addl-transit-handlers)

Client Remote Middleware to add transit encoding for normal Fulcro requests. Sets the content type and transforms an EDN body to a transit+json encoded body. addl-transit-handlers is a map from data type to transit handler (like you would pass using the :handlers option of transit). The additional handlers are used to encode new data types into transit. See transit documentation for more details.

Client Remote Middleware to add transit encoding for normal Fulcro requests. Sets the content type and transforms an EDN
body to a transit+json encoded body. addl-transit-handlers is a map from data type to transit handler (like
you would pass using the `:handlers` option of transit). The
additional handlers are used to encode new data types into transit. See transit documentation for more details.
raw docstring

wrap-fulcro-responseclj/s

(wrap-fulcro-response)
(wrap-fulcro-response handler)
(wrap-fulcro-response handler addl-transit-handlers)

Client remote middleware to transform a network response to a standard Fulcro form.

This returns a function that will decode a transit response iff the resulting status code is 200 and the body is not empty. For errant status codes and empty body: the response body will become an empty map.

No arguments: Returns a function that can process responses, that is not further chained. handler: If supplied, the result of this transformation will be passed through the handler. addl-transit-handlers is equivalent to the :handlers option in transit: a map from data type to handler.

Client remote middleware to transform a network response to a standard Fulcro form.

This returns a function that will decode a transit response iff the resulting status code is 200 and the
body is not empty. For errant status codes and empty body: the response body will become an empty map.

No arguments: Returns a function that can process responses, that is not further chained.
handler: If supplied, the result of this transformation will be passed through the `handler`.
addl-transit-handlers is equivalent to the :handlers option in transit: a map from data type to handler.
raw docstring

xhrio-abortcljs

(xhrio-abort xhrio)

xhrio-disposecljs

(xhrio-dispose xhrio)

xhrio-enable-progress-eventscljs

(xhrio-enable-progress-events xhrio)

xhrio-error-codecljs

(xhrio-error-code xhrio)

xhrio-error-statescljs


xhrio-error-textcljs

(xhrio-error-text xhrio)

xhrio-progressclj/s

(xhrio-progress event)

Given an xhrio progress event, returns a map with keys :loaded and :total, where loaded is the number of bytes transferred in the given phase (upload/download) and total is the total number of bytes to transfer (if known).

Given an xhrio progress event, returns a map with keys :loaded and :total, where loaded is the
number of bytes transferred in the given phase (upload/download) and total is the total number
of bytes to transfer (if known). 
raw docstring

xhrio-raw-errorcljs

(xhrio-raw-error xhrio)

xhrio-response-textcljs

(xhrio-response-text xhrio)

xhrio-sendcljs

(xhrio-send xhrio url verb body headers)

xhrio-status-codecljs

(xhrio-status-code xhrio)

xhrio-status-textcljs

(xhrio-status-text xhrio)

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

× close