# temperjs-store

> State container for JavaScript apps

Latest version **1.0.3** (published 2021-02-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install temperjs-store
pnpm add temperjs-store
yarn add temperjs-store
bun add temperjs-store
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-02-27 |
| First published | 2020-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 74.4 KB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Author | Kenderson Tripaldi |
| Maintainers | ktripaldi |
| Keywords | temperjs-store, temper, temperjs, state, container |

## Links

- npm: https://www.npmjs.com/package/temperjs-store
- Repository: https://github.com/ktripaldi/temperjs
- Homepage: https://temperjs.org
- Issues: https://github.com/ktripaldi/temperjs/issues
- npm.io page: https://npm.io/package/temperjs-store

## Dependencies (1)

- [lodash-es](https://npm.io/package/lodash-es.md) 4.17.20

## 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.3 (latest) — 2021-02-27
- 1.0.2 — 2020-12-28
- 1.0.1 — 2020-12-28

## README

# Temper Store &middot; ![](https://img.shields.io/npm/v/temperjs-store) ![](https://img.shields.io/github/issues/ktripaldi/temperjs-store) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

## Table of contents

- [Installation](#installation)
- [Introduction](#introduction)
- [Usage](#usage)
  - [Actions](#actions)
  - [create](#create)
  - [getTrait](#gettrait)
  - [setTrait](#settrait)
  - [subscribeToTrait](#subscribetotrait)
  - [destroy](#destroy)

### Installation

Using [npm](https://www.npmjs.com/get-npm):

```shell
npm install temperjs-store
```

Using [yarn](https://classic.yarnpkg.com/en/docs/install/):

```shell
yarn add temperjs-store
```

### Introduction

Temper Store is a state container for JavaScript apps.

### Usage

```js
// using ES6 modules
import { storeActions } from 'temperjs-store'

// using CommonJS modules
const storeActions = require('temperjs-store').storeActions

storeActions.setTrait('traitPath', 'traitValue')
```

#### Actions

Temper Store exports an object with the following interface (more details on each action below):

```typescript
interface StoreActions = {
  create(options?: StoreOptions): void
  getTrait<T>(path: string): T | undefined
  setTrait<T>(path: string, traitValue: SetterValue<T>): void
  subscribeToTrait<T>(
    path: string,
    callback: (traitValue: T | undefined) => void,
    defaultValue?: T
  ): Subscription | undefined
  destroy(): void
}
```

#### create

Creates the global store object.

#### getTrait

Returns the value of a Trait.
Traits are globally shared units of state that components can subscribe to.

#### setTrait

Sets the value of a Trait.

#### subscribeToTrait

Subscribes a callback to a Trait and returns a `Subscription` object

#### destroy

Destroys the store.

## Licence

[MIT](LICENSE)

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