Skip to content

Commit

Permalink
v4 (#559)
Browse files Browse the repository at this point in the history
* Adds Generics API and TypeScript improvements (#457)

* Fix statemapper eating up classes

* Remove scratch file

* Adds support for generic values

* Adds support for generic values

* Adds useLocalStore hook, deprecates createComponentStore (#458)

* Adds useLocalStore hook

* Adds typings for useLocalStore and it returns store now too

* Adds docs for useLocalStore

* Updates website

* Bumps version

* Fixes rollup config

* Bumps version

* Fixes website -> docs -> quick-start.md (#453)

* Fixes computed properties error for dynamically added model (#455)

* fixes computed error when get() returns undefined

* avoids implicit boolean conversion

* Bumps version

* Updates website

* Disables eslint against TypeScript files

* Upgrades dependencies

* Modified the useLocalStore API to include prev state/config and change config into a factory function

* Bumps version

* Upgrade website dependencies

* Upgrades dependencies

* Replaces immer-peasy with patched immer

* Bumps version

* Fixes bug with evolved models when rehydrating from merge or mergeDeep strategy

* Bumps version

* Adds patches to npm bundle

* Bumps version

* Adds a script to be able to run patch of immer correctly

* Bumps version

* Improves error handling of immer patch script

* Bumps version

* Fixes TypeScript state mapper

* Bump version

* Removes depth limit on TypeScript state mapper

* Bumps version

* Upgrades dependencies

* Removes prop-types as a dependency

* Adds deprecation message to createComponentStore

* Bumps version

* Small refactor to persistence implementation

* The store.persist.flush API now returns a Promise

* Improves persist flush API and adds types and docs on the store instance persist APIs.

* Bumps version

* Moves to microbundle as our bundler

* Adds mangled properties for internals

* Bump

* Fixes persist data rehydration on dynamically added models and introduces an API by which to await the rehydration.

* Bumps version

* Moves tests to root of project

* Upgrades dependencies

* Fix invalid properties being exposed via getActions in TypeScript

* Fixes listeners TypeScript mappings and removes restrictions.

* Updates dependencies

* Fix state mapper and add giant model stress test

* Upgrades to prettier 2

* Bumps version

* Fixes package lock and runs prettier 2 again

* Fixes and improvements to the TypeScript typings

* Bumps version

* Updates redux-thunk middleware position to allow user overriding via the store middleware config

* Bumps version

* Fixes typings issue for computed properties and updates docs with known issue on them

* Bumps version

* added correct homepage url (#470)

* refactor(recipesDoc): renamed selector to computed (#466)

I believe the name changed a while ago, but wasn't reflected in this doc.

* Adds known issue about computed property destructuring

* shortened links (#469)

* Improves the persist API docs

* Adds community extensions page

* Adds test to ensure immer Set and Map support works as expected

* Adds unstable_effectOn API

* Upgrades depenendencies

* Upgrades to TypeScript 3.9

* Updates website

* Bumps version

* Upgrade dev deps

* Upgrades to immer@7 with supreme joy

* Upgrades TS deps

* Bumps version

* Fixes broken test for debug helper

* Updates website

* Refactors store helpers to be immutable

* Upgrade dev deps

* Upgrades deps

* Bumps version

* Disable persist for server side rendering

* Upgrades dev dependencies

* Upgrades dependencies

* Ensures that storage engines are lazily accessed

* Big rewrite to the persistences documentation

* Minor fixes to typescript definitions

* Bumps version

* don't persist computed fields (#540)

* Simplifies thunks and effects. No more error handling. Introduces an explicity 'fail' API for thunks.

* Component stores drop support for initialData runtime prop and adds support for runtime modification to injections.

* DevTools are now only enabled by default if not in production

* Bumps version

* A minor update to consuming-state.md (#490)

* Update README.md

* Update README.md

* A minor update to consuming-state.md

Co-authored-by: Sean Matheson <sean@ctrlplusb.com>

* Updates docs per @gamtiq PR#507

* Updates docs per @gamtiq PR#508

* Updates docs per @gamtiq PR#509

* Updates docs per @gamtiq PR#517

* Updates docs per @minnacaptain PR#519

* Fix persist transformers order @czeslaaw #514

* Reintroduces initialData as runtimeModel on createContextStore

* Updates website and improves persist API

* Bumps version

* Updates readme

* Updates readme

* Updates readme

* Updates readme

* Updates readme

* Adds new scheduling and optimizations to persisting

* Updates docs

* Bump version

* Computed properties now act againt their original immutable state

* Updates docs and tests

* Bumps version

* Adds versioning to persist API, and new tutorials to website

* Bumps version

* Removes node 8 from travis build

* Updated listeners to not respond to thunk fail type by default

* Updates docs

* Removes esm build

* v4

* Removes temp file

Co-authored-by: Hua Lu <lemonadedrink@gmail.com>
Co-authored-by: Jake Chamberlain <jake@jchamb.com>
Co-authored-by: Mohamed Nainar <mdnainar9615@gmail.com>
Co-authored-by: Matthias Rougier <51899780+Matt-Swingvy@users.noreply.github.com>
Co-authored-by: mighdoll <lee@underneath.ca>
Co-authored-by: Ahmed Mohammed <amElnagdy@users.noreply.github.com>
  • Loading branch information
7 people committed Oct 14, 2020
1 parent cac4642 commit 71ad696
Show file tree
Hide file tree
Showing 160 changed files with 14,064 additions and 7,812 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
@@ -0,0 +1,3 @@
*.d.ts
*.ts
*.tsx
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -7,7 +7,6 @@ cache:
node_js:
- '12'
- '10'
- '8'
script:
# Unfortunately flow falls over when a dep exists in peer deps and others. :(
# @see https://github.com/flowtype/flow-typed/issues/528
Expand Down
127 changes: 127 additions & 0 deletions CODE_OF_CONDUCT.md
@@ -0,0 +1,127 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

- The use of sexualized language or imagery, and sexual attention or advances of
any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address,
without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at [INSERT CONTACT
METHOD]. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
91 changes: 57 additions & 34 deletions README.md
@@ -1,38 +1,60 @@
<p>&nbsp;</p>
<p align='center'>
<img src="https://i.imgur.com/UnPLVly.png" width="280" />
<img src="./website/docs/assets/logo-small.png" width="150" />
</p>
<p align='center'><strong>Vegetarian friendly state for React</strong></p>
<p>&nbsp;</p>


Easy Peasy provides you with an intuitive API to quickly and easily manage the state for your React application. Batteries are included - no configuration is required to support derived state, API calls, performance optimisation, developer tools etc.

[![npm](https://img.shields.io/npm/v/easy-peasy.svg?style=flat-square)](http://npm.im/easy-peasy)
[![MIT License](https://img.shields.io/npm/l/easy-peasy.svg?style=flat-square)](http://opensource.org/licenses/MIT)
[![Travis](https://img.shields.io/travis/ctrlplusb/easy-peasy.svg?style=flat-square)](https://travis-ci.org/ctrlplusb/easy-peasy)
[![Codecov](https://img.shields.io/codecov/c/github/ctrlplusb/easy-peasy.svg?style=flat-square)](https://codecov.io/github/ctrlplusb/easy-peasy)

<p>Easy Peasy is an abstraction of Redux, providing a reimagined API that focuses on <strong>developer experience</strong>. It allows you to <strong>quickly</strong> and <strong>easily</strong> manage your state, whilst leveraging the strong <strong>architectural guarantees</strong> and extensive <strong>eco-system</strong> that Redux has to offer.</p>

<ul>
<li>Zero configuration</li>
<li>No boilerplate</li>
<li>React hooks based API</li>
<li>Extensive TypeScript support</li>
<li>Encapsulate data fetching</li>
<li>Computed properties</li>
<li>Reactive actions</li>
<li>Redux middleware support</li>
<li>State persistence</li>
<li>Redux Dev Tools</li>
<li>Global, context, or local stores</li>
<li>Built-in testing utils</li>
<li>React Native supported</li>
<li>Hot reloading supported</li>
</ul>

<p>&nbsp;</p>

All of this comes via a single dependency install.

```
npm install easy-peasy
```

<p>&nbsp;</p>

**Step 1 - Create your store**
## Fly like an eagle

**Create your store**

```javascript
const store = createStore({
todos: {
items: ['Create store', 'Wrap application', 'Use store'],
add: action((state, payload) => {
state.items.push(payload)
})
}
state.items.push(payload);
}),
},
});
```

**Step 2 - Wrap your application**
**Wrap your application**

```javascript
function App() {
Expand All @@ -44,44 +66,45 @@ function App() {
}
```

**Step 3 - Use the store**
**Use the store**

```javascript
function TodoList() {
const todos = useStoreState(state => state.todos.items)
const add = useStoreActions(actions => actions.todos.add)
const todos = useStoreState((state) => state.todos.items);
const add = useStoreActions((actions) => actions.todos.add);
return (
<div>
{todos.map((todo, idx) => <div key={idx}>{todo}</div>)}
{todos.map((todo, idx) => (
<div key={idx}>{todo}</div>
))}
<AddTodo onAdd={add} />
</div>
)
);
}
```

## Features

- Zero configuration
- No boilerplate
- React hooks based API
- Computed properties - i.e. derived data
- Data fetching / side effects
- Persist state to session/local storage
- Testing helpers
- Extensive TypeScript support
- Global, shared, or component level stores
- React Native supported
- Redux Dev Tools supported
- Hot Reloading supported

## Documentation

See the [official website](https://easy-peasy.now.sh) for tutorials, API docs, recipes, and more.
<p>&nbsp;</p>

## Backers ❤️
## Our Backers ❤️

Extreme gratitude to all our backers! [[Become a backer](https://opencollective.com/easy-peasy#backer)].
We have only but great appreciation to those who support this project. If you
have the ability to help contribute towards the continued maintenance and
evolution of this library then please consider
[[becoming a backer](https://opencollective.com/controlplusb#backer)].

<a href="https://opencollective.com/controlplusb#backers">
<img src="https://opencollective.com/controlplusb/backers.svg?width=950" />
</a>

<p>&nbsp;</p>

## Documentation

See the [official website](https://easy-peasy.now.sh) for tutorials, docs,
recipes, and more.

<p>&nbsp;</p>

## OS Awards Nominee

Easy Peasy was nominated under the "Productivity Booster" category.

0 comments on commit 71ad696

Please sign in to comment.