Update GET_STARTED.md (#119)
This commit is contained in:
parent
949fe935cb
commit
77c7fc969f
1 changed files with 4 additions and 4 deletions
|
@ -112,7 +112,7 @@ A few notes about the example above:
|
||||||
|
|
||||||
- `variableB.derivation.changesWithoutValues()` returns a tappable that we can
|
- `variableB.derivation.changesWithoutValues()` returns a tappable that we can
|
||||||
tap into (observe).
|
tap into (observe).
|
||||||
- The `tap()` method returns the `untap()` function which aborts th
|
- The `tap()` method returns the `untap()` function which unsubscribes the observer function
|
||||||
- As long as `variableB` is tapped (observed) `variableB.derivation.isHot` will
|
- As long as `variableB` is tapped (observed) `variableB.derivation.isHot` will
|
||||||
bet set to `true` automatically
|
bet set to `true` automatically
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ import {prism} from '@theatre/dataverse'
|
||||||
const mousePositionD = prism(() => {
|
const mousePositionD = prism(() => {
|
||||||
// Create an internal state (`pos`) where the position of the mouse
|
// Create an internal state (`pos`) where the position of the mouse
|
||||||
// will be stored, and a function that updates it (`setPos`)
|
// will be stored, and a function that updates it (`setPos`)
|
||||||
const [pos, setPos] = prism.state<[x: number, y: number]>('pos', [0, 0])
|
const [pos, setPos] = prism.state('pos', {x: 0, y: 0})
|
||||||
|
|
||||||
// Create a side effect that attaches the `mousemove` event listeners
|
// Create a side effect that attaches the `mousemove` event listeners
|
||||||
// to the `document`
|
// to the `document`
|
||||||
|
@ -293,14 +293,14 @@ const mousePositionD = prism(() => {
|
||||||
|
|
||||||
// Display the current position of the mouse using a `h2` element
|
// Display the current position of the mouse using a `h2` element
|
||||||
const p = document.createElement('h2')
|
const p = document.createElement('h2')
|
||||||
const [x, y] = mousePositionD.getValue()
|
const {x, y} = mousePositionD.getValue()
|
||||||
p.textContent = `Position of the cursor: [${x}, ${y}]`
|
p.textContent = `Position of the cursor: [${x}, ${y}]`
|
||||||
document.querySelector('body')?.append(p)
|
document.querySelector('body')?.append(p)
|
||||||
|
|
||||||
// Update the element's content when the position of the mouse
|
// Update the element's content when the position of the mouse
|
||||||
// changes
|
// changes
|
||||||
mousePositionD.changesWithoutValues().tap(() => {
|
mousePositionD.changesWithoutValues().tap(() => {
|
||||||
const [x, y] = mousePositionD.getValue()
|
const {x, y} = mousePositionD.getValue()
|
||||||
p.textContent = `Position of the cursor: [${x}, ${y}]`
|
p.textContent = `Position of the cursor: [${x}, ${y}]`
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue