Files

43 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

---
title: Query
sidebar_label: Query
---
2018-08-17 18:43:25 +02:00
Queries are exposed by the platform in the form of `:queries` key in the capacities map.
Only those queries which are exposed can be either referenced by hook property (when the property is of the type `:query`),
or used to read data in let block in view .
2018-08-17 18:43:25 +02:00
## Query as hook property
To refer to some query via hook property (might be required for some host app hooks), the property must be defined as `:query` type
by the app-hook and extension must correctly refer to query from capacities map.
### Example
```clojure
;; Capacities map in the host application
{:capacities {:queries {'network-up ...}}}
2018-08-17 18:43:25 +02:00
;; Extension hook data
hooks/wallet-asset.next-coin
{:able-to-send [network-up]}
2018-08-17 18:43:25 +02:00
```
## Queries in views
To use some queries in extension defined view, the query must be exposed via capacities map of the host platform.
## Example
```clojure
;; Capacities map in the host application
{:capacities {:queries {'store/get ...}}}
2018-08-17 18:43:25 +02:00
;; Extension view data
views/coin-item
[view {}
(let [current-network [store/get {:networks :current}]]
2018-08-17 18:43:25 +02:00
[text {} "Current network: "]
[text {} current-network]])
```