# jet-restate

> Reactive state for Webix Jet apps

Latest version **1.1.0** (published 2020-04-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install jet-restate
pnpm add jet-restate
yarn add jet-restate
bun add jet-restate
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-04-01 |
| First published | 2020-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Maksim Kozhukh |
| Maintainers | mkozhukh |

## Links

- npm: https://www.npmjs.com/package/jet-restate
- Repository: https://github.com/webix-hub/jet-restate
- Homepage: https://github.com/webix-hub/jet-restate#readme
- Issues: https://github.com/webix-hub/jet-restate/issues
- npm.io page: https://npm.io/package/jet-restate

## Recent versions

- 1.1.0 (latest) — 2020-04-01
- 1.0.1 — 2020-02-06

## README

Reactive state for Webix Jet apps
====

## Why it is necessary

Webix Jet provides two ways to cross-view communication

- events
- view parameters, 

Reactive state provides a combination of both, with ability to maintain state ( as parameters ) and ability without predefined source/target ( as events ) 

## How to use

```js
import { createState, link } from "jet-restate";
...
const state = createState({
    mode: config.mode || "grid",
    selectedItem: [],
    search: "",
    path: config.path || "/",
    clipboard: null,
});

this.show("child", { target:"left", params: { state }})
this.show("child", { target:"right", params: { state }})
```

now in any of child views

```js
    const state = this.getParam("state");
    //change state
    state.mode = newValue;
    //react on state changes
    this.on(state.$changes, "mode", value => {
        this.getRoot().setValue(value);
    });
```

#### Extending state

It possible to add new vars to the state.
There is no way to remove them though.

```js
const state = createState({ mode:"grid" });
state.$extend({ path:"/" })
```

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