Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWangJustToDo committed Nov 14, 2023
1 parent fe59f33 commit 0fcde78
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
6 changes: 6 additions & 0 deletions app/createState.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

the state which in the `selector` function is a readonly state, so the only way to change state is in the `action` middleware function.

## v0.2.4 update
new middleware `withDeepSelector` for `createState` support config the selector behavior

## v0.2.6 update
new middleware `withNamespace` for `createState` support `reduxDevTools`

## Simple Code Example

```tsx
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dev:ui": "cd packages/ui && pnpm run dev",
"build:packages": "ts-node ./scripts/rollupBuild.ts",
"build:type": "cd packages/r-store && pnpm run type-gen && cd ../../ && ts-node ./scripts/clearTemp.ts",
"build": "pnpm run build:packages && pnpm run build:type",
"lint": "eslint --cache --ext ts,tsx .",
"lint:fix": "pnpm run lint --fix",
"prettier": "prettier --ignore-path .prettierignore --write .",
Expand Down
45 changes: 44 additions & 1 deletion packages/r-store/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const usePosition = () => {
setState((state) => {
state.x = e.clientX;
state.y = e.clientY;
})
});
};

window.addEventListener("mousemove", listener);
Expand Down Expand Up @@ -252,6 +252,49 @@ const App = () => {
};
```

# v0.2.6 update

### `createState` support `withNameSpace` option for `reduxDevTools` in develop mode

```tsx
import { createState, withActions, withNameSpace } from "reactivity-store";

const useCount = createState(
withActions(
withNameSpace(
() => {
const data = { re: { count: 0 } };

return data;
},
{
namespace: "useCount",
reduxDevTool: true,
}
),
{ generateActions: (state) => ({ add: () => state.re.count++, del: () => state.re.count-- }) }
)
);
```

or

```tsx
import { createState } from "reactivity-store";

const useCount = createState(
() => {
const data = { re: { count: 0 } };

return data;
},
{
withNamespace: "useCount",
withActions: (state) => ({ add: () => state.re.count++, del: () => state.re.count-- }),
}
);
```

## License

MIT
2 changes: 1 addition & 1 deletion packages/r-store/src/shared/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const delDevController = (controller: Controller, state: any) => {
// cache state which has connect to devtool
const devToolMap: Record<string, any> = {};

const globalName = "__reactivity-store__";
const globalName = "__reactivity-store-redux-devtools__";

let globalDevTools = null;

Expand Down
45 changes: 44 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const usePosition = () => {
setState((state) => {
state.x = e.clientX;
state.y = e.clientY;
})
});
};

window.addEventListener("mousemove", listener);
Expand Down Expand Up @@ -252,6 +252,49 @@ const App = () => {
};
```

# v0.2.6 update

### `createState` support `withNameSpace` option for `reduxDevTools` in develop mode

```tsx
import { createState, withActions, withNameSpace } from "reactivity-store";

const useCount = createState(
withActions(
withNameSpace(
() => {
const data = { re: { count: 0 } };

return data;
},
{
namespace: "useCount",
reduxDevTool: true,
}
),
{ generateActions: (state) => ({ add: () => state.re.count++, del: () => state.re.count-- }) }
)
);
```

or

```tsx
import { createState } from "reactivity-store";

const useCount = createState(
() => {
const data = { re: { count: 0 } };

return data;
},
{
withNamespace: "useCount",
withActions: (state) => ({ add: () => state.re.count++, del: () => state.re.count-- }),
}
);
```

## License

MIT

0 comments on commit 0fcde78

Please sign in to comment.