Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Standardized package development, CI, and release workflows on pnpm 11.
- Adopted `@okyrychenko-dev/type-utils` as a direct runtime dependency for shared guards.
- Aligned package exports and validation tooling with the other maintained `@okyrychenko-dev` libraries.
- Deprecated `createStoreToolkit().getProvider()` in favor of the canonical `provider` property.
The compatibility accessor still returns the same Provider bindings without runtime warnings;
removal is deferred to the next intentional major release.

### Removed

Expand Down
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ Each factory uses the same value/plain/API naming pattern:

The provider factory also exposes `useContextStoreOptional` for integrations that
need to detect whether a matching provider is present. The toolkit exposes its
shared provider bindings through `provider`; `getProvider()` returns that same
object when function-based access is useful.
shared provider bindings through `provider`. The deprecated `getProvider()`
compatibility accessor returns that same object and remains available until the
next intentional major release.

## Installation

Expand Down Expand Up @@ -206,7 +207,7 @@ Returns:
- `useStorePlain`
- `useStoreApi`
- `provider`
- `getProvider()`
- `getProvider()` (deprecated; use `provider`)
- `useResolvedStoreApi()`
- `useResolvedValue()`
- `useResolvedStorePlain()`
Expand Down Expand Up @@ -319,14 +320,19 @@ It returns the same resolved hook family used by `createStoreToolkit`:
The deprecated compatibility names have been removed. Replace them with their
canonical equivalents:

| Removed name | Replacement |
| -------------------------------- | --------------------------------------------- |
| `toolkit.createProvider()` | `toolkit.provider` or `toolkit.getProvider()` |
| `useContext()` | `useContextStoreApi()` |
| `useOptionalContext()` | `useContextStoreOptional()` |
| `useResolvedStore()` | `useResolvedStoreApi()` |
| `useResolvedStoreWithSelector()` | `useResolvedValue()` |
| `onStoreCreate` | `onStoreReady` |
| Removed name | Replacement |
| -------------------------------- | --------------------------- |
| `toolkit.createProvider()` | `toolkit.provider` |
| `useContext()` | `useContextStoreApi()` |
| `useOptionalContext()` | `useContextStoreOptional()` |
| `useResolvedStore()` | `useResolvedStoreApi()` |
| `useResolvedStoreWithSelector()` | `useResolvedValue()` |
| `onStoreCreate` | `onStoreReady` |

`getProvider()` remains available as a deprecated compatibility path. Replace
`toolkit.getProvider()` with `toolkit.provider`; both currently return the exact
same Provider bindings object. Its removal is deferred to a separately approved
major release, and calling it does not emit a runtime warning.

`onStoreReady` runs after the provider commits and at most once for each provider
store instance. Use `onStoreInit` when state must be initialized synchronously
Expand Down
2 changes: 1 addition & 1 deletion src/core/__tests__/createStoreToolkit.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe("createStoreToolkit", () => {
expect(toolkit.useStorePlain).toBeDefined();
expect(toolkit.useStoreApi).toBeDefined();
expect(toolkit.provider).toBeDefined();
expect(toolkit.getProvider).toBeDefined();
expect(toolkit.useResolvedStoreApi).toBeDefined();
expect(toolkit.useResolvedValue).toBeDefined();
expect(toolkit.useResolvedStorePlain).toBeDefined();
Expand All @@ -32,6 +31,7 @@ describe("createStoreToolkit", () => {
count: 0,
increment: () => set((state) => ({ count: state.count + 1 })),
}));
// eslint-disable-next-line @typescript-eslint/no-deprecated -- Verifies the compatibility path.
expect(toolkit.provider).toBe(toolkit.getProvider());
});

Expand Down
4 changes: 4 additions & 0 deletions src/types/store-toolkit.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ import type { StoreMutatorTuple } from "./store.types";
export interface StoreToolkit<TState, TMutators extends Array<StoreMutatorTuple> = []>
extends ShallowStoreBindings<TState, TMutators>, ResolvedStoreBindings<TState, TMutators> {
provider: StoreProviderResult<TState, TMutators>;
/**
* @deprecated Use {@link provider} instead. This compatibility accessor will be removed in the
* next intentional major release.
*/
getProvider: () => StoreProviderResult<TState, TMutators>;
}
Loading