Smart map is a Pathom interface that provides a map-like data structure, but this structure will realize the values as the user requests then. Values realized are cached, meaning that subsequent lookups are fast.
Smart map is a Pathom interface that provides a map-like data structure, but this structure will realize the values as the user requests then. Values realized are cached, meaning that subsequent lookups are fast.
(datafy-smart-map sm)
Returns a map with all reachable keys from the smart map. The cached keys get their
value in this map, unresolved keys return with the special value ::pcr/unknown-value
.
This is helpful to use with REPL tools that support the Clojure Datafiable/Navitable protocols. On navigation Pathom try to load the attribute you navigate to.
Returns a map with all reachable keys from the smart map. The cached keys get their value in this map, unresolved keys return with the special value `::pcr/unknown-value`. This is helpful to use with REPL tools that support the Clojure Datafiable/Navitable protocols. On navigation Pathom try to load the attribute you navigate to.
(sm-assoc! smart-map k v)
Assoc on the smart map in place, this function mutates the current cache and return the same instance of smart map.
You should use this only in cases where the optimization is required, try starting with the immutable versions first, given this has side effects and so more error phone.
Assoc on the smart map in place, this function mutates the current cache and return the same instance of smart map. You should use this only in cases where the optimization is required, try starting with the immutable versions first, given this has side effects and so more error phone.
(sm-dissoc! smart-map k)
Dissoc on the smart map in place, this function mutates the current cache and return the same instance of smart map.
You should use this only in cases where the optimization is required, try starting with the immutable versions first, given this has side effects and so more error phone.
Dissoc on the smart map in place, this function mutates the current cache and return the same instance of smart map. You should use this only in cases where the optimization is required, try starting with the immutable versions first, given this has side effects and so more error phone.
(sm-entity sm)
Return the source cached entity for the smart map
Return the source cached entity for the smart map
(sm-env smart-map)
Extract the env map from the smart map.
Extract the env map from the smart map.
(sm-env-assoc env k v)
Creates a new smart map by adding k v to the initial context.
When you read information in the smart map, that information is cached into an internal atom, and any dependencies that were required to get to the requested data is also included in this atom.
When you assoc into a smart map, it will discard all the data loaded by Pathom itself and will be like you have assoced in the original map and created a new smart object.
Creates a new smart map by adding k v to the initial context. When you read information in the smart map, that information is cached into an internal atom, and any dependencies that were required to get to the requested data is also included in this atom. When you assoc into a smart map, it will discard all the data loaded by Pathom itself and will be like you have assoced in the original map and created a new smart object.
(sm-env-contains? env k)
Check if a property is present in the cache-tree.
Check if a property is present in the cache-tree.
(sm-env-dissoc env k)
Creates a new smart map by adding k v to the initial context.
When you read information in the smart map, that information is cached into an internal atom, and any dependencies that were required to get to the requested data is also included in this atom.
When you assoc into a smart map, it will discard all the data loaded by Pathom itself and will be like you have assoced in the original map and created a new smart object.
Creates a new smart map by adding k v to the initial context. When you read information in the smart map, that information is cached into an internal atom, and any dependencies that were required to get to the requested data is also included in this atom. When you assoc into a smart map, it will discard all the data loaded by Pathom itself and will be like you have assoced in the original map and created a new smart object.
(sm-env-empty env)
Return a new smart map with the same environment and an empty map context.
Return a new smart map with the same environment and an empty map context.
(sm-env-find env k)
Check if attribute can be found in the smart map.
Check if attribute can be found in the smart map.
(sm-env-get env k)
(sm-env-get {:com.wsscode.pathom3.entity-tree/keys [entity-tree*] :as env}
k
default-value)
Get a property from a smart map.
First it checks if the property is available in the cache-tree, if not it triggers the connect engine to lookup for the property. After the lookup is triggered the cache-tree will be updated in place, note this has a mutable effect in this data, but this change is consistent.
Repeated lookups will use the cache-tree and should be as fast as reading from a regular Clojure map.
Get a property from a smart map. First it checks if the property is available in the cache-tree, if not it triggers the connect engine to lookup for the property. After the lookup is triggered the cache-tree will be updated in place, note this has a mutable effect in this data, but this change is consistent. Repeated lookups will use the cache-tree and should be as fast as reading from a regular Clojure map.
(sm-env-keys {:com.wsscode.pathom3.interface.smart-map/keys [keys-mode]
:as env})
Retrieve the keys in the smart map cache-tree.
Retrieve the keys in the smart map cache-tree.
(sm-env-meta env)
Returns meta data of smart map, which is the same as the meta data from context map used to create the smart map.
Returns meta data of smart map, which is the same as the meta data from context map used to create the smart map.
(sm-env-with-meta env meta)
Return a new smart-map with the given meta.
Return a new smart-map with the given meta.
(sm-get-with-stats sm k)
Return the graph run analysis, use for debugging. You can find the get value return in the ::psm/value key.
Note that if the value is cached, there will be a blank stats.
Return the graph run analysis, use for debugging. You can find the get value return in the ::psm/value key. Note that if the value is cached, there will be a blank stats.
(sm-replace-context sm new-context)
Replace the context data for the smart map with new-context, keeping the same environment. This returns a new smart map.
Replace the context data for the smart map with new-context, keeping the same environment. This returns a new smart map.
(sm-touch! smart-map eql)
Will pre-fetch data in a smart map, given the EQL request. Use this to optimize the load of data ahead of time, instead of pulling one by one lazily.
Will pre-fetch data in a smart map, given the EQL request. Use this to optimize the load of data ahead of time, instead of pulling one by one lazily.
(sm-update-env sm f & args)
Update smart map environment
Update smart map environment
(smart-map env)
(smart-map {:com.wsscode.pathom3.interface.smart-map/keys [persistent-cache?]
:or {persistent-cache? true}
:as env}
context)
Create a new smart map.
Smart maps are a special data structure that realizes properties using Pathom resolvers.
They work like maps and can be used interchangeable with it.
To create a smart map you need send an environment with the indexes and a context map with the initial context data:
(smart-map (pci/register [resolver1 resolver2]) {:some "context"})
When the value of a property of the smart map is a map, that map will also be cast into a smart map, including maps inside collections.
Create a new smart map. Smart maps are a special data structure that realizes properties using Pathom resolvers. They work like maps and can be used interchangeable with it. To create a smart map you need send an environment with the indexes and a context map with the initial context data: (smart-map (pci/register [resolver1 resolver2]) {:some "context"}) When the value of a property of the smart map is a map, that map will also be cast into a smart map, including maps inside collections.
(smart-run-stats run-stats)
Wrap runner run stats with smart definitions to traverse the runner data.
Wrap runner run stats with smart definitions to traverse the runner data.
(with-error-mode env error-mode)
This configures what happens when some error occur during the Pathom process to provide more data to the Smart Map.
Available modes:
::error-mode-silent (default): Return nil
as the value, don't throw errors.
::error-mode-loud: Throw the errors on read.
This configures what happens when some error occur during the Pathom process to provide more data to the Smart Map. Available modes: ::error-mode-silent (default): Return `nil` as the value, don't throw errors. ::error-mode-loud: Throw the errors on read.
(with-keys-mode env key-mode)
Configure how the Smart Map should respond to keys
.
Available modes:
::keys-mode-cached (default): in this mode, keys will return only the keys that are currently cached in the Smart Map. This is the safest mode, given it will only read things from memory.
::keys-mode-reachable: in this mode, keys will list all possible keys that Pathom can reach given the current indexes and available data. Be careful with this mode, on large graphs there is a risk that a scan operation (like printing it) may trigger a large amount of resolver processing.
Configure how the Smart Map should respond to `keys`. Available modes: ::keys-mode-cached (default): in this mode, keys will return only the keys that are currently cached in the Smart Map. This is the safest mode, given it will only read things from memory. ::keys-mode-reachable: in this mode, keys will list all possible keys that Pathom can reach given the current indexes and available data. Be careful with this mode, on large graphs there is a risk that a scan operation (like printing it) may trigger a large amount of resolver processing.
(with-wrap-nested? env wrap?)
Configure smart map to enable or disable the automatic wrapping of nested structures.
Configure smart map to enable or disable the automatic wrapping of nested structures.
(wrap-smart-map {:com.wsscode.pathom3.interface.smart-map/keys [wrap-nested?]
:or {wrap-nested? true}
:as env}
x)
If x is a composite data structure, return the data wrapped by smart maps.
If x is a composite data structure, return the data wrapped by smart maps.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close