Liking cljdoc? Tell your friends :D

com.fulcrologic.rad.routing.history

Generic history protocol and support.

In order to use history, you must install an implementation on your Fulcro app at application start-time that is compatible with your runtime environment (browser, native mobile, etc.) via install-route-history!. Once you've done that, then the non-protocol methods in this namespace can be used against the app to update the history, but they will not affect the actual application route. Actual routing should always be done via the com.fulcrologic.rad.routing namespace functions, which will keep track of history if it is installed.

Generic history protocol and support.

In order to use history, you must install an implementation on your Fulcro app at application start-time that
is compatible with your runtime environment (browser, native mobile, etc.) via `install-route-history!`. Once
you've done that, then the non-protocol methods in this namespace can be used against the app to update the *history*,
but they will *not* affect the actual *application route*. Actual routing should always be done via the
`com.fulcrologic.rad.routing` namespace functions, which will keep track of history if it is installed.
raw docstring

active-historyclj/s

(active-history app-ish)

Returns the active (installed) RouteHistory implementation, or nil if none is installed.

Returns the active (installed) RouteHistory implementation, or nil if none is installed.
sourceraw docstring

add-route-listener!clj/s

(add-route-listener! app-or-component listener-key f)

Add the callback f to the list of listeners. That listener will be known as listener-key. You should namespace that key to prevent conflicts.

Add the callback `f` to the list of listeners. That listener will be known as `listener-key`. You should namespace that key to prevent conflicts.
sourceraw docstring

back!clj/s

(back! app-or-component)

Go to the last position in history (if history is installed).

Go to the last position in history (if history is installed).
sourceraw docstring

current-routeclj/s

(current-route app-or-component)

Returns a map of {:route ["a" "b"] :params {}}. The params are the extra state/params, and the route is purely strings.

Returns a map of {:route ["a" "b"] :params {}}. The params are the extra state/params, and the route is purely strings.
sourceraw docstring

history-support?clj/s

(history-support? app-ish)

Returns true if RAD history support is enabled on the given app (you can also pass a component).

Returns true if RAD history support is enabled on the given app (you can also pass a component).
sourceraw docstring

install-route-history!clj/s

(install-route-history! app history)
(install-route-history! app history route-predicate)

Installs an implementation of RouteHistory onto the given Fulcro app.

route-predicate is an optional (fn [app route params]) that should return true if the route change is allowed, and false otherwise. The default value is (fn [app _ _] (dr/can-change-route? app)).

Installs an implementation of RouteHistory onto the given Fulcro app.

`route-predicate` is an optional `(fn [app route params])` that should return true
if the route change is allowed, and false otherwise. The default value is
`(fn [app _ _] (dr/can-change-route? app))`.
sourceraw docstring

push-route!clj/s

(push-route! app-or-component target route-params)

Push the given route onto the route history (if history is installed).

Push the given route onto the route history (if history is installed).
sourceraw docstring

remove-route-listener!clj/s

(remove-route-listener! app-or-component listener-key)

Remove the listener named listener-key.

Remove the listener named `listener-key`.
sourceraw docstring

replace-route!clj/s

(replace-route! app-or-component target route-params)

Replace the top of the current route stack

Replace the top of the current route stack 
sourceraw docstring

RouteHistoryclj/sprotocol

A Route History is mainly a storage device. It records a history stack along with optional additional parameters at each history entry. It can be asked what it thinks the current route is, and it can be asked to replace the current top of the stack.

A history implementation may be hooked to some external source of events (i.e. browser back/forward buttons, phone native navigation). These events (e.g. like HTML5 popstate events) are only expected when there is an external change to the route that your application did not initiate with its own API (not that A tags in HTML with URIs will cause these events, since it is the browser, not your app, that is technically initiating the change). Such an implementation must honor the add/remove calls to hook up a listener to these external events.

A Route History is mainly a storage device. It records a history stack along with optional additional parameters
at each history entry. It can be asked what it thinks the current route is, and it can be asked to replace the
current top of the stack.

A history implementation *may* be hooked to some external source of events (i.e. browser back/forward buttons, phone
native navigation). These events (e.g. like HTML5 popstate events) are only expected when there is an *external* change
to the route that your application did not initiate with its own API (not that A tags in HTML with URIs will cause
these events, since it is the browser, not your app, that is technically initiating the change). Such an implementation
*must* honor the add/remove calls to hook up a listener to these external events.

-add-route-listener!clj/s

(-add-route-listener! history listener-key f)

Add the callback f to the list of listeners. That listener will be known as listener-key. You should namespace that key to prevent conflicts.

Add the callback `f` to the list of listeners. That listener will be known as `listener-key`. You should namespace that key to prevent conflicts.

-back!clj/s

(-back! history)

Moves the history back one in the history stack. Calling this will result in a route listener notification about the new route.

Moves the history back one in the history stack. Calling this will result in a route listener notification about the new route.

-current-routeclj/s

(-current-route history)

Returns a map of {:route ["a" "b"] :params {}}. The params are the extra state/params, and the route is purely strings. Note that changing the route may be an async operation, so do not expect this to be the correct route immediately after a call to -back!; use a route listener instead. This particular method is useful for checking when the Fulcro app's idea of the current route differs from the current route in history (i.e. as a sanity check when Fulcro's state changes)

Returns a map of {:route ["a" "b"] :params {}}. The params are the extra state/params, and the route is purely strings.
Note that changing the route may be an async operation, so do *not* expect this to be the correct route immediately after
a call to `-back!`; use a route listener instead. This particular method is useful for checking when the Fulcro
app's idea of the current route differs from the current route in history (i.e. as a sanity check when Fulcro's state changes)

-push-route!clj/s

(-push-route! history route params)

Pushes the given route with params onto the current history stack.

Pushes the given route with params onto the current history stack.

-remove-route-listener!clj/s

(-remove-route-listener! history listener-key)

Remove the listener named listener-key.

Remove the listener named `listener-key`.

-replace-route!clj/s

(-replace-route! history route params)

Replaces the top entry in the history stack.

Replaces the top entry in the history stack.

-undo!clj/s

(-undo! history new-route params)

Attempt to undo the given (last) change to history that was reported to listeners. new-route and params are the parameters that were passed to the listener. This can only be done once, and will fail silently if no such notification just happened (or isn't possible).

Attempt to undo the given (last) change to history that was reported to listeners. `new-route` and `params` are the
parameters that were passed to the listener. This can only be done once,
and will fail silently if no such notification just happened (or isn't possible).
sourceraw docstring

undo!clj/s

(undo! app-or-component new-route new-params)

Undo the (last) request to route that was delivered to a listener. Must be passed that parameters that were passed to the listener. Idempotent: calling this more than once will only have an effect once.

Undo the (last) request to route that was delivered to a listener. Must be passed that parameters that were passed
to the listener. Idempotent: calling this more than once will only have an effect once.
sourceraw docstring

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

× close