<commit_before># Reduxless

> A small state management library for unidirectional data flow.

## Introduction

Reduxless provides a store you can subscribe to and issue queries and commands against. It's intended to be a lightweight alternative to Redux or Flux with a simplified interface.

It only has three methods:

  - `subscribe(onChange: function)`: subscribes a listener called `onChange` to receive notifications when the store values change
  - `get(key: string)`: returns the value of `key`
  - `set(key: string, value: any)`: sets the value of `key`

## Creating the store

To create a store, call the `createStore()` function:

```js
import createStore from 'reduxless';

const initialValues = { name: 'Bart', surname: 'Simpson' };
const store = createStore(initialValues);

const report = () =>
  console.log(`Store has changed! – ${store.get('name')} ${store.get('surname')}`);

store.subscribe(report);
store.set('name', 'Homer');
```

## Using the store in a React-like library

To use the store with a React-like library, you can use the library-specific `Container` component to wrap your components using the store.

Here's an example using [Preact](https://preactjs.com/):

```js
import { h, render } from 'preact';
import createStore from 'reduxless';
import Container from 'reduxless/preact';

const store = createStore({ name: '<NAME>' });

render(
  <Container store={store}>
    {store =>
      <p onClick={() => store.set('name', '<NAME>')}>
        Hello there, {store.get('name')}! Click to change me.
      </p>
    }
  </Container>
)
```

We provide the following Container components (must be installed as a peer dependency):

  - React: `reduxless/react`
  - Preact `reduxless/preact`
  - Inferno: `reduxless/inferno`

### Rendering performance gains using `mapper`
There is also a `mapper` function which behaves in a similar fashion to Redux's `connect`, ie, it expects two arguments: `mapStateToProps` and `mapStateToActions`. The component returned by `mapper` will only render it's children after the store has changed if the relevant props have also changed. It's a good idea to use a memoization library like [reselect](https://github.com/reselect) for further performance gains. 

```js
import { h, render } from 'preact';
import createStore from 'reduxless';
import Container from 'reduxless/preact';

const store = createStore({ name: '<NAME>' });

const Component = ({name, update}) => (<commit_msg>fixed reselect lib url<commit_after># Reduxless

> A small state management library for unidirectional data flow.

## Introduction

Reduxless provides a store you can subscribe to and issue queries and commands against. It's intended to be a lightweight alternative to Redux or Flux with a simplified interface.

It only has three methods:

  - `subscribe(onChange: function)`: subscribes a listener called `onChange` to receive notifications when the store values change
  - `get(key: string)`: returns the value of `key`
  - `set(key: string, value: any)`: sets the value of `key`

## Creating the store

To create a store, call the `createStore()` function:

```js
import createStore from 'reduxless';

const initialValues = { name: 'Bart', surname: 'Simpson' };
const store = createStore(initialValues);

const report = () =>
  console.log(`Store has changed! – ${store.get('name')} ${store.get('surname')}`);

store.subscribe(report);
store.set('name', 'Homer');
```

## Using the store in a React-like library

To use the store with a React-like library, you can use the library-specific `Container` component to wrap your components using the store.

Here's an example using [Preact](https://preactjs.com/):

```js
import { h, render } from 'preact';
import createStore from 'reduxless';
import Container from 'reduxless/preact';

const store = createStore({ name: '<NAME>' });

render(
  <Container store={store}>
    {store =>
      <p onClick={() => store.set('name', '<NAME>')}>
        Hello there, {store.get('name')}! Click to change me.
      </p>
    }
  </Container>
)
```

We provide the following Container components (must be installed as a peer dependency):

  - React: `reduxless/react`
  - Preact `reduxless/preact`
  - Inferno: `reduxless/inferno`

### Rendering performance gains using `mapper`
There is also a `mapper` function which behaves in a similar fashion to Redux's `connect`, ie, it expects two arguments: `mapStateToProps` and `mapStateToActions`. The component returned by `mapper` will only render it's children after the store has changed if the relevant props have also changed. It's a good idea to use a memoization library like [reselect](https://github.com/reactjs/reselect) for further performance gains. 

```js
import { h, render } from 'preact';
import createStore from 'reduxless';
import Container from 'reduxless/preact';

const store = createStore({ name: '<NAME>' });

const Component = ({name, update}) => (
{'fraction_non_alphanumeric': 0.12135427289414644, 'fraction_numerical': 0.0, 'mean_word_length': 4.630309988518944, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5343751', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1386, 'n_words': 583}