diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index c5bc1ed..613752e 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -14,6 +14,6 @@ module.exports = {
'warn',
{ allowConstantExport: true },
],
- 'no-console': ['error', { allow: ['warn', 'error'] }],
+ 'no-console': ['error', { allow: ['info', 'warn', 'error'] }],
},
}
diff --git a/README.md b/README.md
index d9d356c..5f8a388 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
# Overview
An elegant state management solution for React.
+The philosophy of this project is to keep the core simple and scalable by exposing low-level accessibility and middleware composition, not by adding options.
+All the non-core functions are just examples of how you can compose functions to achieve common features.
## Features
@@ -8,7 +10,8 @@ An elegant state management solution for React.
- **Type safe**: The state is type safe and the return value is intuitive.
- **Global**: The state is global, you can access it anywhere.
- **Scalable**: Naturally scale large state into multiple modules and files without performance degradation.
-- **Tiny**: Less than [0.3KB](https://bundlephobia.com/package/create-global-state).
+- **Middlewares**: Simple and type-safe middleware composition interface.
+- **Tiny**: About [0.3KB](https://bundlephobia.com/package/create-global-state) Minified + Gzipped.
## Documentation
@@ -46,3 +49,4 @@ Its implementation is not type safe and the return value is not intuitive. It's
The typescript support is not good enough, the API is not intuitive. `create-global-state` is more like `useState` which aligns with the react API style. Check the [comparison](https://github.com/ysmood/create-global-state/issues/1). Zustand [Slices Pattern](https://zustand.docs.pmnd.rs/guides/slices-pattern) can cause naming conflict issues.
`create-global-state` can naturally scale states by modules and files.
+The setter of zustand must be called within a react component, while the setter of `create-global-state` can be called anywhere.
diff --git a/cspell.json b/cspell.json
new file mode 100644
index 0000000..b958163
--- /dev/null
+++ b/cspell.json
@@ -0,0 +1,13 @@
+{
+ "words": [
+ "gettify",
+ "immer",
+ "immerify",
+ "subscribify",
+ "todomvc",
+ "todos",
+ "tsbuildinfo",
+ "wouter",
+ "zustand"
+ ]
+}
diff --git a/examples/CounterPersistent.tsx b/examples/CounterPersistent.tsx
index c591094..946258a 100644
--- a/examples/CounterPersistent.tsx
+++ b/examples/CounterPersistent.tsx
@@ -1,4 +1,4 @@
-import create from "create-global-state/lib/persistent";
+import create, { saveHistory } from "create-global-state/lib/persistent";
import { useEffect } from "react";
import { useHashLocation } from "wouter/use-hash-location";
@@ -22,7 +22,11 @@ export default function CounterPersistent() {
}
function Button() {
- return ;
+ return (
+
+ );
}
function Display() {
diff --git a/examples/MonolithStore/store/index.ts b/examples/MonolithStore/store/index.ts
index 6568fb4..ffce86f 100644
--- a/examples/MonolithStore/store/index.ts
+++ b/examples/MonolithStore/store/index.ts
@@ -1,6 +1,6 @@
// Here we use Immer to update the store immutably, Immer is optional,
// you can use vanilla js or other libs to update the store.
-import create from "create-global-state/lib/immer";
+import { create } from "create-global-state/lib/immer";
// Define the monolith store for the entire web app.
// It contains a list of counters and a title string.
diff --git a/examples/TodoApp/Actions.tsx b/examples/TodoApp/Actions.tsx
index 4f3262e..478bbc7 100644
--- a/examples/TodoApp/Actions.tsx
+++ b/examples/TodoApp/Actions.tsx
@@ -1,6 +1,6 @@
import Filter from "./Filter";
-import { addTodo, clearCompleted } from "./todos/actions";
-import { useZeroDone } from "./todos";
+import { addTodo, clearCompleted } from "./store/actions";
+import { useZeroDone } from "./store/todos";
import ToggleAll from "./ToggleAll";
export default function Actions() {
diff --git a/examples/TodoApp/Filter.tsx b/examples/TodoApp/Filter.tsx
index a80ad3c..516a566 100644
--- a/examples/TodoApp/Filter.tsx
+++ b/examples/TodoApp/Filter.tsx
@@ -1,7 +1,11 @@
-import { filters, setFilter } from "./todos/filter";
+import { useEffect } from "react";
+import { setFilter } from "./store/filter";
+import { filters } from "./store/filter/types";
// The component to filter the todos.
export default function Filter() {
+ useEffect(() => {});
+
return (