Skip to content

Commit

Permalink
Version Packages (#5213)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and github-actions[bot] authored Feb 24, 2025
1 parent 0332a16 commit 80db725
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 41 deletions.
40 changes: 0 additions & 40 deletions .changeset/six-foxes-deny.md

This file was deleted.

41 changes: 41 additions & 0 deletions packages/xstate-store/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
# @xstate/store

## 3.2.0

### Minor Changes

- [#5200](https://github.com/statelyai/xstate/pull/5200) [`0332a16a42fb372eb614df74ff4cb7f003c31fc8`](https://github.com/statelyai/xstate/commit/0332a16a42fb372eb614df74ff4cb7f003c31fc8) Thanks [@{](https://github.com/{)! - Added selectors to @xstate/store that enable efficient state selection and subscription:

- `store.select(selector)` function to create a "selector" entity where you can:
- Get current value with `.get()`
- Subscribe to changes with `.subscribe(callback)`
- Only notify subscribers when selected value actually changes
- Support custom equality functions for fine-grained control over updates via `store.select(selector, equalityFn)`

```ts
const store = createStore({
context: {
position: { x: 0, y: 0 },
name: 'John', age: 30 }
},
on: {
positionUpdated: (
context,
event: { position: { x: number; y: number } }
) => ({
...context,
position: event.position
})
}
});

const position = store.select((state) => state.context.position);

position.get(); // { x: 0, y: 0 }

position.subscribe((position) => {
console.log(position);
});

store.trigger.positionUpdated({ x: 100, y: 200 });
// Logs: { x: 100, y: 200 }
```

## 3.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/xstate-store/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xstate/store",
"version": "3.1.0",
"version": "3.2.0",
"description": "Simple stores",
"keywords": [
"store",
Expand Down

0 comments on commit 80db725

Please sign in to comment.