Skip to content

Commit

Permalink
Update docs: add read and write CTF
Browse files Browse the repository at this point in the history
  • Loading branch information
orenelbaum committed Mar 18, 2022
1 parent 4f8baf0 commit 29bdb40
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,19 @@

const $a = createSignal(0);
<MyComp {...{ $a, $b: $a }} $c={$a} d={$a[0]()} />


// Read and write CTF

import { read, write } from 'babel-plugin-reactivars-solid'

let $sig = 0
const sigGetter = read($sig)
const sigSetter = write($sig)

// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓

const $sig = createSignal(0)
const sigGetter = $sig[0]
const sigSetter = $sig[1]

19 changes: 19 additions & 0 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,22 @@ const Comp1 = () => {
</>
}
```


## Read and write CTFs

You can use the `read` and `write` compile time functions to get the getter and setter of a reactive variable directly without using the `$` function.

```js
import { read, write } from 'babel-plugin-reactivars-solid'

let $sig = 0
const sigGetter = read($sig)
const sigSetter = write($sig)

// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓

const $sig = createSignal(0)
const sigGetter = $sig[0]
const sigSetter = $sig[1]
```

0 comments on commit 29bdb40

Please sign in to comment.