Functions for making and consuming Fulcro temporary IDs. Tempids are used when the client is optimistically creating a new entity and you want to be able to detect that on the server when the data is sent. Additionally, Fulcro mutations can return a remapping instruction from the server to rewrite all tempids in the client (state, network queues, etc.) atomically.
This allows the client to safely generate new entities with a temporary ID and let the server remap them to the real
IDs at some future time. Transit read/write is included, so that (de)serialization of them can be consistent whenever
needed (see the transit
ns in this package).
Functions for making and consuming Fulcro temporary IDs. Tempids are used when the client is optimistically creating a new entity and you want to be able to detect that on the server when the data is sent. Additionally, Fulcro mutations can return a remapping instruction from the server to rewrite all tempids in the client (state, network queues, etc.) atomically. This allows the client to safely generate new entities with a temporary ID and let the server remap them to the real IDs at some future time. Transit read/write is included, so that (de)serialization of them can be consistent whenever needed (see the `transit` ns in this package).
(resolve-tempids data-structure tid->rid)
Replaces all tempids in data-structure
using the tid->rid
map. This is just a deep
walk that replaces every possible match of tid
with rid
.
tid->rid
must be a map, as this function optimizes away resolution by checking if
the map is empty.
Returns the data structure with everything replaced.
Replaces all tempids in `data-structure` using the `tid->rid` map. This is just a deep walk that replaces every possible match of `tid` with `rid`. `tid->rid` must be a map, as this function optimizes away resolution by checking if the map is empty. Returns the data structure with everything replaced.
(resolve-tempids! {:com.fulcrologic.fulcro.application/keys [state-atom
runtime-atom]}
tx-result)
Resolve all of the mutation tempid remappings in the tx-result
against the given app
.
app - The fulcro app tx-result - The transaction result (the body map, not the internal tx node).
This function rewrites all tempids in the app state and runtime transaction queues.
NOTE: This function assumes that tempids are distinctly recognizable (e.g. are TempIds or guids). It is unsafe to use this function if you're using something else for temporary IDs as this function might rewrite things that are not IDs.
Resolve all of the mutation tempid remappings in the `tx-result` against the given `app`. app - The fulcro app tx-result - The transaction result (the body map, not the internal tx node). This function rewrites all tempids in the app state and runtime transaction queues. NOTE: This function assumes that tempids are distinctly recognizable (e.g. are TempIds or guids). It is unsafe to use this function if you're using something else for temporary IDs as this function might rewrite things that are not IDs.
(result->tempid->realid tx-result)
Find and combine all of the tempid remappings from a standard fulcro transaction response.
Find and combine all of the tempid remappings from a standard fulcro transaction response.
(tempid)
(tempid uuid)
(tempid)
(tempid id)
Create a new tempid.
Create a new tempid.
(tempid? x)
Returns true if the given x
is a tempid.
Returns true if the given `x` is a tempid.
(uuid)
(uuid n)
(uuid)
(uuid & args)
Generate a UUID. With no args returns a random UUID. with an arg (numeric) it generates a stable one based on that number (useful for testing). Works in cljc.
Generate a UUID. With no args returns a random UUID. with an arg (numeric) it generates a stable one based on that number (useful for testing). Works in cljc.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close