This repository has been archived by the owner on Nov 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[new packages] - @reffect/strict @reffect/undoable + [new version] - …
…@reffect/react 1.1.3 (#9) * [new package] @reffect/undoable (#7) * feat: initial commit for reffect-undoable package, add simplest implementation undo redo * feat: create simple undo redo store extension package * chore: change build config (output plugins) * chore: remove build files * chore: add gitignore for reffect/undoable * chore: lock file update * feat: rewrite undoable to reffect store with couple effects (undo, redo) * chore: up size limits for reffect undoable package; chore: change keywords for undoable * docs: update readme for monorepo (add Install section); docs: add readme for undoable package * [new package] @reffect/strict (#8) * feat: add the "strict" package; fix(@reffect/react): problems with unmounted react hooks * bump: @reffect/react to 1.1.3 * docs: update README for strict * chore: set initial version for strict package * docs: update README , CHANGELOG * docs: fix badge in new packages READMEs
- Loading branch information
Showing
19 changed files
with
444 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# 1.1.3 | ||
|
||
### Fix: | ||
|
||
1. update hooks states only if hook is mounted | ||
|
||
# 1.1.2 | ||
|
||
### Minor: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
reffect-strict.*.js | ||
reffect-strict.d.ts | ||
reffect-strict.*.js.map | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
{ | ||
"path": "reffect-strict.es.js", | ||
"webpack": false, | ||
"limit": "310 B" | ||
}, | ||
{ | ||
"path": "reffect-strict.cjs.js", | ||
"webpack": false, | ||
"limit": "340 B" | ||
}, | ||
{ | ||
"path": "reffect-strict.umd.js", | ||
"webpack": false, | ||
"limit": "450 B" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 0.0.1 | ||
|
||
Created project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<div align="center"> | ||
|
||
[![reffect logo](https://raw.githubusercontent.com/acacode/reffect/master/assets/reffect.png)](https://github.com/acacode/reffect) | ||
[![npm](https://img.shields.io/npm/v/@reffect/strict?style=flat-square&color=blue)](https://www.npmjs.com/package/@reffect/strict) | ||
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@reffect/strict?style=flat-square&color=blue)](https://bundlephobia.com/result?p=@reffect/strict) | ||
[![license](https://img.shields.io/github/license/acacode/reffect?style=flat-square&color=blue)](https://github.com/acacode/reffect) | ||
|
||
<div align="left"> | ||
|
||
Reffect — is a declarative and reactive multi-store state manager for JavaScript/TypeScript applications inspired by [Reatom](https://github.com/artalar/reatom) and [Effector](https://github.com/zerobias/effector) | ||
|
||
# @reffect/strict | ||
|
||
Store middleware for [`Reffect`](https://github.com/acacode/reffect) | ||
|
||
## How to use | ||
|
||
```ts | ||
import { store, effect } from "@reffect/core"; | ||
import { strictUpdate } from "@reffect/logger"; | ||
|
||
const projectsStore = store({ projects: [] }, "projects", [strictUpdate]); | ||
|
||
const setProjects = effect(projectsStore, "projects"); | ||
// ... | ||
|
||
setProjects(["foo", "bar"]); // state of projectsStore will update to { projects: ["foo", "bar"] } | ||
setProjects(["foo", "bar"]); // state of projectsStore won't update because new state and current are equals | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "@reffect/strict", | ||
"version": "0.0.1", | ||
"description": "strict update store middleware for Reffect", | ||
"scripts": { | ||
"build": "node ../../build/build.js", | ||
"size": "size-limit" | ||
}, | ||
"author": "acacode", | ||
"license": "MIT", | ||
"readme": "README.md", | ||
"private": false, | ||
"sideEffects": false, | ||
"main": "reffect-strict.cjs.js", | ||
"typings": "reffect-strict.d.ts", | ||
"umd:main": "reffect-strict.umd.js", | ||
"jsnext:main": "reffect-strict.es.js", | ||
"module": "reffect-strict.es.js", | ||
"peerDependencies": { "@reffect/core": "^1.5.0" }, | ||
"devDependencies": { | ||
"@reffect/core": "^1.5.0", | ||
"@size-limit/preset-small-lib": "^4.2.1", | ||
"size-limit": "^4.2.1" | ||
}, | ||
"files": [ | ||
"LICENSE", | ||
"reffect-strict.d.ts", | ||
"reffect-strict.cjs.js", | ||
"reffect-strict.cjs.js.map", | ||
"reffect-strict.es.js", | ||
"reffect-strict.es.js.map", | ||
"reffect-strict.umd.js", | ||
"reffect-strict.umd.js.map" | ||
], | ||
"keywords": [ | ||
"redux", | ||
"effector", | ||
"mobx", | ||
"state", | ||
"store", | ||
"flux", | ||
"reactive", | ||
"state-manager", | ||
"state manager", | ||
"reffect" | ||
], | ||
"gitHead": "a724ce9d6d802cf83fec609ad4664172a4694471" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { StoreType, manage } from "@reffect/core"; | ||
|
||
const equals = (obj1: object, obj2: object): obj1 is typeof obj2 => { | ||
if (obj1 === obj2) return true; | ||
if (!(obj1 instanceof Object) || !(obj2 instanceof Object)) return false; | ||
if (obj1.constructor !== obj2.constructor) return false; | ||
|
||
for (const property in obj1) { | ||
if (obj1.hasOwnProperty(property) && (!obj2.hasOwnProperty(property) || !equals(obj1[property], obj2[property]))) | ||
return false; | ||
} | ||
|
||
for (const property in obj2) { | ||
if (obj2.hasOwnProperty(property) && !obj1.hasOwnProperty(property)) return false; | ||
} | ||
return true; | ||
}; | ||
|
||
export const strictUpdate = <Store extends StoreType>(store: Store, copy: (obj: object) => object) => { | ||
const storeManager = manage(store); | ||
const originalPartialUpdate = storeManager.partialUpdate; | ||
|
||
storeManager.partialUpdate = (storeUpdate: Partial<Store>) => | ||
storeUpdate && | ||
!equals(store, copy({ ...storeManager.state, ...storeUpdate })) && | ||
originalPartialUpdate(storeUpdate); | ||
|
||
return store; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
reffect-undoable.*.js | ||
reffect-undoable.d.ts | ||
reffect-undoable.*.js.map | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
{ | ||
"path": "reffect-undoable.es.js", | ||
"webpack": false, | ||
"limit": "410 B" | ||
}, | ||
{ | ||
"path": "reffect-undoable.cjs.js", | ||
"webpack": false, | ||
"limit": "450 B" | ||
}, | ||
{ | ||
"path": "reffect-undoable.umd.js", | ||
"webpack": false, | ||
"limit": "550 B" | ||
} | ||
] |
Oops, something went wrong.