# quicksandjs

> Data management solution using change events

Latest version **1.0.1** (published 2017-10-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install quicksandjs
pnpm add quicksandjs
yarn add quicksandjs
bun add quicksandjs
```

## 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.0.1 |
| Published | 2017-10-15 |
| First published | 2017-10-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | CalebBlack |
| Maintainers | calebblack |
| Keywords | state, quicksand, javascript, data, management |

## Links

- npm: https://www.npmjs.com/package/quicksandjs
- Repository: https://github.com/CalebBlack/QuicksandJS
- Homepage: https://github.com/CalebBlack/QuicksandJS#readme
- Issues: https://github.com/CalebBlack/QuicksandJS/issues
- npm.io page: https://npm.io/package/quicksandjs

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-10-15
- 1.0.0 — 2017-10-15

## README

# Quicksand.JS
Quicksand is a state/data management solution. It is based upon creating listeners for data change events.

## Paths
Paths are where your data is stored. It represents the path of objects in the internal data object, and is formatted by joining each part of the parts with periods.

```first.second.third```

## Methods

#### set
The set method sets the value at the specified path with any value.

```qs.onChange(path,value)```

#### get
The get method allows you to get the value at the specified path.

```qs.get(path)```

#### onChange
The onChange method allows you to add a function to be called when the data at a given path is changed. The new value and the old value and the path are passed to the function.

```qs.onChange(path,function)```

#### didChange
The didChange method allows you to set the function to determine whether the onChange functions should be called (the function should return a boolean value). Unlike the onChange method, there can only be one didChange per path, so calling this multiple times on the same path will just override your previous functions.

```qs.didChange(path,function)```


## Example
```
const Quicksand = require('quicksandjs');
let state = new Quicksand();
let path = 'a.b.c';
state.onChange(path,(newValue,oldValue)=>{
  console.log(newValue,oldValue);
})
state.didChange(path,(newValue,oldValue)=>{return typeof newValue != typeof oldValue});
state.set(path,'firstvalue');
state.set(path,'secondvalue')```

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