-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular Signal Store #195
Angular Signal Store #195
Conversation
…e into signal-store-tests
Signal store tests
reducer manager needs a default reducer to prevent "null pointers" when initialising the store without registered reducers
Getting an upstream dependency conflict error when running
|
@carlos-ds |
|
||
for (let i = 0; i < reducerKeyLength; i++) { | ||
const key = reducerKeys[i]; | ||
const reducer: any = reducers[key]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why this is explicitly typed as any
? That seems unnecessary and incorrect, since it is inferred as Reducer<any>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reducer is indeed better than any.
@@ -0,0 +1,87 @@ | |||
import { deepFreeze } from './deep-freeze'; | |||
|
|||
// Created a cool set of unit tests with ChatGPT: https://chat.openai.com/share/f2a078c9-e996-4d4e-8c4c-725ca2e9cafd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this comment can be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to be transparent about copy-pasted stuff from ChatGPT or stack-overflow.
The comment text I adjusted a little bit now.
return 42; | ||
}; | ||
expect(() => deepFreeze(fn)).not.toThrow(); | ||
// Test that the function object is frozen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems obsolete? Same for the other comments that state 'Test that ... is/are frozen'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed two not useful comments. The others have at least a little bit extra information which could be useful.
// Prevent effect to unsubscribe from the actions stream | ||
export function defaultEffectsErrorHandler<T>( | ||
observable$: Observable<T>, | ||
retryAttemptLeft = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think retryAttemptsLeft
would be better in a grammatical sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, retryAttemptsLeft it is :)
…l-store # Conflicts: # package.json
See the RFC for more information about the MiniRx Signal Store.
A pre-release version (build from this PR code) has been published on NPM: https://www.npmjs.com/package/@mini-rx/signal-store
This PR also contains a new library: @mini-rx/common: common contains shared code which is used by Signal Store and will be used by the original mini-rx-store in the future. @mini-rx/common will be installed as a dependency of Signal Store.
The Signal Store API is very similar to the original mini-rx-store, these are the main differences:
effect
function)rxEffect
in FeatureStore/ComponentStore supports Signal as trigger (next to Observable and raw value)setInitialState
anymore in FeatureStore/ComponentStore for lazy state initialisation. An initialState is required, which is more inline with native Angular Signals.select
methods return Signal instead of Observableconnect
method was added to FeatureStore/ComponentStore to easily connect the stores with external Signals/ObservablessetState
does not accept an Observable anymore (useconnect
instead)createSelector
,createFeatureStateSelector
use Angularcomputed
internally for memoization. The selector creation functions return a function which takes a Signal and returns a Signal.You can find more info about the changed APIs in this blogpost: https://dev.to/this-is-angular/minirx-signal-store-for-angular-api-preview-4e16