1.0.15 • Published 3 years ago

@visly/state v1.0.15

Weekly downloads
421
License
MIT
Repository
-
Last release
3 years ago

Visly State · GitHub license npm version Tests

React state for real-time apps.

Installation

Visly State works with React & Node.js, whether you use JavaScript or TypeScript.

Install it using npm:

npm install @visly/state

or yarn:

yarn add @visly/state

Creating your first state

This example shows how we can store global application state, read & display it in our UI, and finally how to update the state. The component will automatically re-render when the count changes as it is subscribed to it by calling useValue.

import { state, useValue, useMutation } from '@visly/state'

const appState = state({ count: 0 })

function Component() {
    const count = useValue(appState, s => s.count)
    const increment = useMutation(appState, s => s.count++)

    return (
        <div>
            <span>{count}</span>
            <button onClick={increment}>increment</button>
        </div>
    )
}

For more detailed usage see the documentation.

1.0.15

3 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.10

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago