# @arhamill/cortex

> Reactive library for corda

Latest version **1.1.5** (published 2020-02-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install @arhamill/cortex
pnpm add @arhamill/cortex
yarn add @arhamill/cortex
bun add @arhamill/cortex
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2020-02-07 |
| First published | 2020-01-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 24.3 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Angus Hamill |
| Maintainers | arhamill |

## Links

- npm: https://www.npmjs.com/package/@arhamill/cortex
- Repository: https://github.com/arhamill/cortex
- Homepage: https://github.com/arhamill/cortex#readme
- Issues: https://github.com/arhamill/cortex/issues
- npm.io page: https://npm.io/package/@arhamill/cortex

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.19.2
- [sse.js](https://npm.io/package/sse.js.md) ^0.4.4

## Recent versions

- 1.1.5 (latest) — 2020-02-07
- 1.1.4 — 2020-02-07
- 1.1.3 — 2020-02-07
- 1.1.2 — 2020-02-07
- 1.1.1 — 2020-02-07
- 1.1.0 — 2020-02-03
- 1.0.0 — 2020-01-31

## README

# Cortex: A reactive library for the Corda vault

### Guide to usage

Install cortex
```
npm install @arhamill/cortex
```
Run the [cortex webserver](https://github.com/arhamill/cortex-server)
```
docker run -p 8080:8080 -v "<cordapp-directory>":/opt/cortex/cordapps arhamill/cortex
```
Create a corda context and provider component
```
import { createLinearContext } from '@arhamill/cortex'

const nft = createLinearContext('http://cortex-server-url', 'com.r3.corda.lib.tokens.contracts.states.NonFungibleToken')
const nftContext = nft.linearContext
const NFTProvider = nft.LinearProvider
```
Add the provider as a parent to any component that needs to consume it (either within itself or any of its children). For convenience this will usually be the `App` component.
```
ReactDOM.render(
    <NFTProvider>
        <App />
    </NFTProvider>
, document.getElementById('root'));
```
Consume the context from any child component!
```
import React, { useContext } from 'react'

const MyComponent = () => {
    const nfts = useContext(nftContext)

    ...
}
```

Any component consuming this context will be re-rendered when there is a vault update.

## Full API documentation

Create a context provider for token-sdk fungible tokens:
```
createTokensContext(url)
```

Create a context provider for any linear state (order of linear ids is preserved):
```
createLinearContext(url, stateClass)
```

Create a context provider for any contract state:
```
createStateContext(url, stateClass)
```

---
_Source: https://npm.io/package/@arhamill/cortex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
