Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:07
    timdeschryver commented #3016
  • 13:21
    jrista commented #3016
  • 11:25
    brandonroberts closed #2884
  • 11:25
    brandonroberts commented #2884
  • 11:24
    brandonroberts labeled #2890
  • 11:24
    brandonroberts labeled #2890
  • 11:09
    Ruslancic opened #3019
  • 08:31
    mix5003 commented #3010
  • May 13 21:33

    brandonroberts on rxjs7

    chore: update to RxJS 7 fix(store): add support for RxJ… fix(effects): add support for R… and 1 more (compare)

  • May 13 14:03
    timdeschryver commented #3016
  • May 13 12:54

    brandonroberts on 12.0.0

    (compare)

  • May 13 12:54

    brandonroberts on master

    chore: release 12.0.0 (compare)

  • May 12 20:01
    wiegell edited #3018
  • May 12 20:00
    wiegell opened #3018
  • May 11 02:24

    brandonroberts on master

    docs(entity): fix selectedUserI… (compare)

  • May 11 02:24
    brandonroberts closed #3017
  • May 11 02:24

    brandonroberts on v12-migration

    (compare)

  • May 11 02:24

    brandonroberts on master

    docs(store): add selector depre… (compare)

  • May 11 02:24
    brandonroberts closed #3015
  • May 10 22:42
    ngrxbot commented #3017
Dave Bush
@DaveMBush

I wondered if anyone has created any "updater" scripts that would bring my code from class based/Type enum/switch based NgRX to the new create* syntax (yeah, I know it isn't really "new" any more but my company has just gotten around to upgrading from Ng7 to Ng11.)

So far, the best I've been able to come up with is a macro that uses Regular Expressions and search and replace. I was just hoping there was something smarter out there.

Patrick Thomas
@NoVaJava_gitlab
I feel like I should know this. I am storing a status field in the store to check the success of a save before I move to another step. I am using a selector to get the observable for the value. I am subscribing to the observable to detect any changes to the status. I tested it, and it works. I want to make sure that subscribing to the observable does not emit the current value in the store, which may be left over from a previous save attempt. Did I miss anything?
Patrick Thomas
@NoVaJava_gitlab
That is the way I thought it worked. Thanks. I see what I did now to make it work. I was setting the status in a step before subscribing, which is why I wasn't seeing the previous value. That is the behavior I want, but I cannot guarantee that the status will be reset from the previous one before the subscription happens. I am still stuck on this problem.
Dave Bush
@DaveMBush
@NoVaJava_gitlab subscriptions always wait for the next value unless you've turned them into a subject by using the share() operator. So, store.select(selector).subscribe() will wait for the next value but store.select(selector).pipe(share()).subscribe() will retrieve whatever happens to be in the store at the time.
of course, using share() with skip(1) gives you the same behavior as not using share()
Patrick Thomas
@NoVaJava_gitlab
I thought selecting from a store behaved as a BehaviorSubject which "will return the initial value or the current value on Subscription"
Andreas Weinzierl
@this-is-me:matrix.org
[m]
Me, too
Gordon Lawrenz
@DeusProx

Hello! I'm trying to figure out how to test an selector (selectAll from and EntityAdapter) from a FeatureState. E.g.:

export const selectFeatureState = createFeatureSelector<EntityState<fromModel.ModelWithId>>('FeatureKey');

export const selectAll = createSelector(
    selectFeatureState,
    fromModel.entityAdapter.getSelectors().selectAll
)

It normally seems to work but sometimes my tests are flaky:

    const items: ModelWithId[] = [
        { id: 2 },
        { id: 1 },
    ] as any;
    const entityState = createEntityAdapter<ModelWithId>().setAll(items, fromModel.initialState);
    const featureState = { [fromSelector.featureKey]: entityState };

    // Sometimes flaky
    describe('selectAll', () => {
        it('should return all cached items', () => {
            expect(fromSelector.selectAll(featureState)).toEqual(items);
        });
    });

I searched in quite a few resources, but I'm still unsure if the selector or the way I test or even something I don't consider could be wrong. Any hint would be helpful.

GOVINDA ALWANI
@govi2010

Hello team I am getting below TSLint issue.
Package is buiding fine and working fine.

Argument type () => Observable<TypedAction<"[WidgetInfo] init failed"> | ({data: IClientListResp} & TypedAction<"[Channels] get channels list success">)> is not assignable to parameter type () => (Observable<TypedAction<"[WidgetInfo] init failed"> | ({data: IClientListResp} & TypedAction<"[Channels] get channels list success">)> & ConditionallyDisallowActionCreator<DispatchType<EffectConfig>, Observable<TypedAction<"[WidgetInfo] init failed"> | ({data: IClientListResp} & TypedAction<"[Channels] get channels list success">)>>)

here is my code,

  getChannelsListSuccess$ = createEffect(() => this.actions$.pipe(
    ofType(actions.getChannelListSuccess),
    exhaustMap(({ data }) => {
      let { channels, ...client } = data;
      return [actions.setClient({ client: client as IClient }), actions.setChannels({ channels: channels })];
    }),
    catchError((err) => {
      console.log(err);
      return of(actions.initWidgetFailed());
    })));

I am using webstrome as editor

Harpush
@Harpush
Hey can anyone answer me how good action hygiene can be combined with DRY? It seems that if say books store should know all namespaces of the ones calling it in reducer - a few rules are violated - DRY, open close and maybe more. On the other hand having one action which is dispatched from many places is against the good action hygiene... Any ideas?
Andreas Weinzierl
@this-is-me:matrix.org
[m]
Yeah it's a bit weird
Andreas Weinzierl
@this-is-me:matrix.org
[m]
What you can do is resolving DRY within the reducers. So if two actions do the same, call a function that generates the new state
Harpush
@Harpush
@this-is-me:matrix.org still breaks open close... I have to keep increasing the switch cases for every new feature communicating with this store
Andreas Weinzierl
@this-is-me:matrix.org
[m]
Don't you have to do that with bad action hygiene, too?
Harpush
@Harpush
Nope... Say i have xaction i can just invoke ot from several places - the reducer knows only one action. Compared to many actions with context thta the reducer knows and keeps increasing
Andreas Weinzierl
@this-is-me:matrix.org
[m]

But in this case the open closed principle does not even apply: you don't extend the reducer.

And you have to be lucky that you can use a action multiple times (meaning extending the reducer). Sometimes it works, sometimes not.

As of good action hygiene, think of it as moving the logic of binding an action to a state change from the store consumer (likely a smart component) to the reducer.
Andreas Weinzierl
@this-is-me:matrix.org
[m]

:point_up: Edit: But in this case the open closed principle does not even apply: you don't extend the reducer.

And you have to be lucky that you can use a action multiple times (meaning not extending the reducer). Sometimes it works, sometimes not.

Harpush
@Harpush
But it still means books store for example knows all other stores or smart components dispatching the actions
Andreas Weinzierl
@this-is-me:matrix.org
[m]
Why does the books store know all other stores?
Regarding smart components: at least it knows it's actions - it doesn't need to know about the component, does it?
Andreas Weinzierl
@this-is-me:matrix.org
[m]
I wonder how to split the store and the components into different modules though:
If the store must access the actions from the component and the component must access the selectors of the store - seems like an impossible situation
Vladislav Hadzhiyski
@hadzhiyski
Hello,
Does anyone has any issues with ngrx/entity 10.1.2 ? The adapter selectors don't seem to work when the route changes. I am using router-store 10.1.2 and I wonder if it's connected.
Gerard
@1304654_gitlab
Hello everyone! I have a question, I have a component-store that stores a list of "Items" for example these items contain customers, what should I do to update the status of an item? so that it is separated into two classes: itemList services and the other itemClient service. Or the only option I have is to update the entire list every time an item is modified?
Radu Grama
@RaduGrama
We're getting selector to emit twice. We expect it to emit once, as a result of an action changing the state. We see no actions (expected), we just see the selector emit again seconds later, on top of that with modified data. We can't figure out why. Anything we should be aware that would cause a selector to fire like that?
Frank
@TechnicalFreak

We are using microfrontends developed in separate angular projects as webcomponents. Each microfrontend has its own ngrx-store. I think, the state is working correctly. But the devtools are not working as expected. I explained the problem here ngrx/platform#2986

Additional infos:
My shell app starts with an "@@INIT" event. My initialstate is undefined. But it should contain a value.

My microfrontend starts with an "@ngrx/store/init" event and contains the initialstate of the shell app:)

After the first dispatch in each store, it seems working better. After using locking and unlocking button in the devtools, the state between the two apps partially changes from one store to the other. The initialstate of the shell app keeps in the wrong store.

Switching between root and feature states or settings the reducer later after window loaded doesn't help.

Any idea?
:)

Jv
@jayvhaile
Hello, I have created some generic effect class which i extend and use for multiple actions, and after putter the generic effect class in an angular library, they never got called, it used to run when this generic class was in the same project
Colin Laws
@ColinLaws
@RaduGrama I heard that using facades in front of NGRX can cause a common tricky bug where selectors fire twice!
In order to mitigate this, you can use createSelector. If you are using facades and running into this issue, I'd recommend checking out: https://www.youtube.com/watch?v=OZam9fNNwSE
Aurore
@DarkAurore
Hi everyone, just a quick question: when using angular material for displaying general notifications (using snackbar), is it a good practice to use an Effect that will directly reference MatSnackBar and contain the code to display it; or is it better to only have a selector that would return a NotificationState (containing the message) and use it in AppComponent to display the MatSnackBar when it changes ? (ie the code for matsnackbar would be in appComponent.ts, and not in the effect)
Colin Laws
@ColinLaws
@DarkAurore I would say you'd probably want to build yourself an action that would reduce to a change in your snackbar's message you are tracking in your store. You could build an effect that would run a timeout and then push a subsequent action to close the snackbar. That's the plan for something I'm working on at the moment. Hope that helps!
Colin Laws
@ColinLaws
@DarkAurore Also, you should be selecting the state of the snackbar from the store in your MatSnackBar component with a selector. You don't want to tightly couple anything together by doing direct references from your effects to your components. Push actions that reduce to changes in your store, and your snackbar component should be observing the visibility state in your store. Then the side effect could count down a given timeout, then at the end of that count down, push a subsequent action that sets the visibility state of the snackbar in the store. That way, your snackbar component is just concerned with display logic, pulling its state from the store
@DarkAurore Though, if you do need logic to initially display the snackbar by calling open, I can see where that would make sense to put that in a side effect, absolutely. Sorry to blow up the channel everyone, just want to help out.
Aurore
@DarkAurore
thanks a lot for your input @ColinLaws :) the only thing is, there is already a timeout functionality to auto-close a snackbar so it kinda works the other way around in that case, i can push an action when the snackbar ref is closed (subscribing to afterDismissed event) to indicate that my notification is hidden in the state... but doing it "the right way" (action that sets visibility state => selector on it => close snackbar when hidden) is adding complexity when in fact the auto close behaviour is handled by material already, isn't it a bit overkill to add an Effect with our own timeout just to trigger a specific close action ourselves ?
Remco Huizenga
@GRHuizenga
Hey everyone, I am working on an Angular app and we are using ngrx for state management and when possible, we use ngrx/data. Now we are running into the situation where we would like to override the ngrx/data DataService url's for a given entity. E.g. for deleting an entity it generates urls of the form <api_root>/entity/id but in this case we are dealing with related data and thus the desired url would be of the form <api_root>/parent_entity/parent_id/child_entity/child_id. Of course we can just register a custom data service for the child entity and construct the url ourselves, but we would like to find a more robust solution that we can use for every entity that requires it. It wouldnt be too hard to write a custom http url generator, except for the fact that the parent_id is dynamic (in our case, we take it from the route params) and this dynamic behavior makes it hard to find a good, generic solution. Has anyone ever encountered this and has a solution? (I've seen it mentioned in this thread a couple times, going back a few years, but never with a solution). Thanks in advance!
Henrik Lagerholm
@nac0n

Hi there all,
My team and i are working on an enterprise application with Angular and ngrx, i've been directed here via google after searching for an issue with immutability in ngrx and angular when using angular's DynamicComponentHostDirective and it's function "createComponent()". I saw that the issue can be solved by disabling the strictStateImmutability in app.module.ts and that works fine.

runtimeChecks: { strictStateImmutability: false, strictActionImmutability: false },

My question is rather if there's any plans on solving this issue in ngrx, or if there's a workaround to enable strictStateImmutability while using the createComponent-function?

Peter
@piotrpalek
hey, I have a question regarding component-store. I've used tapResponse instead of tap for any side effect related code, but I've noticed that tapResponse seems to swallow thrown errors (like "ReferenceErrors" etc), probably because of catchError(() => EMPTY) that's used inside of it. Is that how it's supposed to work?
Or am I just using tapResponse for the wrong stuff and should just use tap instead?
Henrik Lagerholm
@nac0n

@piotrpalek The syntax you're describing is wrong though? catchError() shouldn't be inside tapResponse()but instead you should use common callback-functions in tapResponse(), as docs describe it:
tapResponse<T>(nextFn: (next: T) => void, errorFn: (error: unknown) => void, completeFn?: () => void): (source: Observable<T>) => Observable<T>

I also don't think tapResponse() and catchError() should be used alongside one another.
In our enterprise-project, we use tap() to handle side effects (an simple example is console.log). And catchError() to handle errors that have occured. And in case we want to do things regardless of error or not we use finalize()-operator. I can be wrong but this is how we handle it.

Peter
@piotrpalek
@nac0n what I meant was that tapResponse itself uses catchError inside of it
and that causes some errors to be silently squashed
Peter
@piotrpalek
how do I catch the error thrown in the "success" handler of tapResponse? It just gets silently swallowed
Andreas Weinzierl
@this-is-me:matrix.org
[m]
What's the best way to handle inserting objects spanning two entities?
I somehow need to know the ids before passing objects to the reducer.
@this-is-me:matrix.org it's a limitation of the library
you need to add your own logic
Andreas Weinzierl
@this-is-me:matrix.org
[m]
am I introducing a race condition if I retrieve the ID from the store and without any API calls return the appropriate action in an effect?