react-rock 3.1.6 → 3.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +7 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-rock",
3
- "version": "3.1.6",
3
+ "version": "3.1.8",
4
4
  "author": "Naxrul Ahmed",
5
5
  "description": "React-Rock is a modern, lightweight state management library designed to simplify handling global state in React applications. With a minimal API and powerful features like freezing data updates for optimized re-renders, React-Rock allows you to manage state more efficiently while ensuring your app remains fast and responsive.",
6
6
  "main": "./index.js",
package/readme.md CHANGED
@@ -32,10 +32,11 @@ import { createStore } from 'react-rock';
32
32
 
33
33
  // Define RowType and MetaType
34
34
  type RowType = { name: string, age: number };
35
- type MetaType = { totalRecords: number };
35
+ type MetaType = { anykey: any };
36
36
 
37
+ const default_rows = [{ name: '', age: 0 }]
37
38
  // Create a store
38
- const users = createStore<RowType, MetaType>({ name: '', age: 0 }, { totalRecords: 0 });
39
+ const users = createStore<RowType, MetaType>(default_rows, { anykey: '' });
39
40
 
40
41
  // Add a new row to the store
41
42
  users.create({ name: 'John Doe', age: 30 });
@@ -83,7 +84,7 @@ Here’s a table with all available methods and their descriptions:
83
84
  The `find` method allows you to search for rows in the store based on specific conditions:
84
85
 
85
86
  ```typescript
86
- const foundUsers = users.find({ name: 'John Doe' } });
87
+ const foundUsers = users.find({ name: 'John Doe' } );
87
88
  console.log(foundUsers);
88
89
  ```
89
90
 
@@ -157,10 +158,10 @@ class UserList extends StoreComponent {
157
158
  users.create({ name: 'Alice', age: 25 });
158
159
 
159
160
  // Update a user
160
- users.update({ age: 26 }, { name: 'Alice' } });
161
+ users.update({ age: 26 }, { name: 'Alice' } );
161
162
 
162
163
  // Delete a user
163
- users.delete({ name: 'Alice' } });
164
+ users.delete({ name: 'Alice' } );
164
165
  ```
165
166
 
166
167
  ## Examples with `find` and Query
@@ -171,7 +172,7 @@ const usersOver25 = users.find({ age: { gt: 25 } });
171
172
  console.log(usersOver25);
172
173
 
173
174
  // Find the first user with the name 'Alice'
174
- const alice = users.findFirst({ name: 'Alice' } });
175
+ const alice = users.findFirst({ name: 'Alice' } );
175
176
  console.log(alice);
176
177
  ```
177
178