Skip to content

Commit 2e4f51e

Browse files
authored
Merge pull request #50 from zuriscript:release/17.1.0
Last small fixes for Release 17.1.0
2 parents 3af6181 + 0ac35de commit 2e4f51e

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ signalstory is a state management library based on angular signals. It offers a
4040
- 🌌 If your store becomes too complex and bloated, slice it into multiple stores.
4141
- ✨ Join and aggregate your state at the component level using signal mechanics.
4242
- 🌐 Need to sync states between stores synchronously? - Use events.
43-
- 🔮 Need to decouple actors and consumers as you do in ``redux`? - Use events.
43+
- 🔮 Need to decouple actors and consumers as you do in `redux`? - Use events.
4444
- 🔄 Craving `Immutability`? - Just activate it.
4545
- 🏎️ Don't want full immutability because your store has to be super fast? - Don't activate it.
4646
- 🧙‍♂️ Seeking a way to encapsulate side effects in a reusable, maintainable, and testable way? - Use effect objects.
4747
- 🔍 Want a way to reuse and test queries spanning over multiple stores? - Use query objects.
4848
- 📦 Don't want to use a class for stores? - You don't have to.
4949
- 🛠️ Tired of debugging state changes in the console? - Enable redux devtools.
5050
- 🪄 Still want some good old logging magic? - Enable Store logger plugin
51-
- ⏳ Need to keep track of store history and selectively perform undo/redo operations? - Enable the history plugin.
51+
- ⏳ Need to keep track of store history and perform undo/redo operations? - Enable the history plugin.
5252
- 💾 Want to sync your state with local storage? - Enable the persistence plugin.
5353
- 📈 Need to get notified of whether your store is modified or currently loading? - Enable the Store Status plugin.
5454
- 🎨 Something's missing? - Write a custom plugin.

packages/signalstory/README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@
1212

1313
signalstory is a state management library based on angular signals. It offers a range of architectural options, from simple repository-based state management (`signal-in-a-service`) to decoupled commands, managed side effect objects, and inter-store communication using an event-based approach. The goal is to provide a great user experience for all developers, whether junior or senior, while incorporating all the features you need to master your frontend state requirements.
1414

15-
## Philosophy
15+
> Starting out? You can keep it nice and simple if you prefer to avoid exploring all the advanced features that a state management library can offer! Begin by checking out the [store](https://zuriscript.github.io/signalstory/docs/store), and only dive into the rest if you're curious later on.
16+
17+
## Guiding Principles
1618

1719
- 🚀 Use class methods to provide controlled access and mutations to shared state.
1820
- 🌌 If your store becomes too complex and bloated, slice it into multiple stores.
1921
- ✨ Join and aggregate your state at the component level using signal mechanics.
2022
- 🌐 Need to sync states between stores synchronously? - Use events.
21-
- 🔮 Need to decouple actors and consumers as you do in redux? - Use events.
22-
- 🔄 Craving Immutability? - Just activate it.
23+
- 🔮 Need to decouple actors and consumers as you do in `redux`? - Use events.
24+
- 🔄 Craving `Immutability`? - Just activate it.
2325
- 🏎️ Don't want full immutability because your store has to be super fast? - Don't activate it.
2426
- 🧙‍♂️ Seeking a way to encapsulate side effects in a reusable, maintainable, and testable way? - Use effect objects.
2527
- 🔍 Want a way to reuse and test queries spanning over multiple stores? - Use query objects.
2628
- 📦 Don't want to use a class for stores? - You don't have to.
2729
- 🛠️ Tired of debugging state changes in the console? - Enable redux devtools.
28-
- ⏳ Need to keep track of store history and selectively perform undo/redo operations? - Enable the history plugin.
30+
- 🪄 Still want some good old logging magic? - Enable Store logger plugin
31+
- ⏳ Need to keep track of store history and perform undo/redo operations? - Enable the history plugin.
2932
- 💾 Want to sync your state with local storage? - Enable the persistence plugin.
33+
- 📈 Need to get notified of whether your store is modified or currently loading? - Enable the Store Status plugin.
3034
- 🎨 Something's missing? - Write a custom plugin.
3135
- 📖 Read the [docs](https://zuriscript.github.io/signalstory/) for more features and concepts.
3236

@@ -49,12 +53,13 @@ class BookStore extends ImmutableStore<Book[]> {
4953
super({
5054
initialState: { ... },
5155
name: 'Books Store',
52-
enableLogging: true,
5356
mutationProducerFn: produce,
5457
plugins: [
5558
useDevtools(),
59+
useLogger(),
5660
useStoreHistory(),
57-
useStorePersistence()
61+
useStorePersistence(),
62+
useStoreStatus(),
5863
],
5964
});
6065

@@ -82,18 +87,20 @@ class BookStore extends ImmutableStore<Book[]> {
8287

8388

8489
// Encapsulated multi store query object
85-
export const BooksAndVendorsByAuthorInSwitzerlandQuery = createQuery(
86-
[BookStore, VendorStore],
87-
(books, vendors, authorId: string) => {
90+
export const BooksAndPublishersByAuthorInSwitzerlandQuery = createQuery(
91+
[BookStore, PublisherStore],
92+
(books, publishers, authorId: string) => {
8893
const booksFromAuthor = books.state().filter(x => x.author === authorId);
89-
const vendorsInSwitzerland = vendors.state().filter(x => x.country === 'CH');
94+
const publishersInSwitzerland = publishers.state().filter(x => x.country === 'CH');
9095

9196
return booksFromAuthor.map(book => ({
9297
book,
93-
vendors: vendorsInSwitzerland.find(vendor => vendor.id === book.vendorId),
98+
publisher: publishersInSwitzerland.find(p => p.id === book.mainPublisherId),
9499
}));
95100
}
96101
);
102+
// And then run it
103+
const query = myBookStore.runQuery(BooksAndPublishersByAuthorInSwitzerlandQuery, 'sapowski');
97104

98105
// Encapsulated effect object
99106
export const fetchBooksEffect = createEffect(
@@ -109,8 +116,16 @@ export const fetchBooksEffect = createEffect(
109116
}),
110117
tap(result => store.setBooks(result))
111118
);
119+
},
120+
{
121+
setLoadingStatus: true, // indicates that the store is loading while the effect runs
122+
setUnmodifiedStatus: true, // it should mark the store as unmodified upon completion
112123
}
113124
);
125+
// And then run it
126+
myBookStore.runEffect(fetchBooksEffect).subscribe();
127+
const loadingSignal = isLoading(myBookStore); // true while effect is running
128+
const isModifiedSignal = isModified(myBookStore); // false after store update
114129
```
115130

116131
## Sample Application

packages/signalstory/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "signalstory",
3-
"version": "17.0.1",
3+
"version": "17.1.0",
44
"description": "Signal-based state management for Angular applications",
55
"publishConfig": {
66
"access": "public"

0 commit comments

Comments
 (0)