Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 11:29
    sumitparakh commented #1563
  • 08:44
    maartentibau commented #1470
  • 04:35

    brandonroberts on master

    feat(router-store): add action… (compare)

  • 04:35
    brandonroberts closed #2272
  • 04:35
    brandonroberts closed #2206
  • 04:33

    brandonroberts on ngrx-conf-announcement

    (compare)

  • 04:33

    brandonroberts on master

    docs(marketing): add ngrx conf … (compare)

  • 04:33
    brandonroberts closed #2292
  • Dec 12 21:04
    Jefiozie commented #2287
  • Dec 12 20:53
    jordanpowell88 commented #2287
  • Dec 12 16:55

    wardbell on master

    docs(data): correct doc for dis… (compare)

  • Dec 12 16:55
    wardbell closed #2290
  • Dec 12 16:55
    wardbell closed #2288
  • Dec 11 16:57
    Jefiozie commented #2227
  • Dec 11 16:07
    ngrxbot commented #2292
  • Dec 11 15:56
    timdeschryver synchronize #2292
  • Dec 11 15:56

    timdeschryver on ngrx-conf-announcement

    Update _marketing-layout.scss (compare)

  • Dec 11 15:36
    ngrxbot commented #2292
  • Dec 11 15:25
    timdeschryver synchronize #2292
  • Dec 11 15:25

    timdeschryver on ngrx-conf-announcement

    docs: add announcement bar (compare)

Daniel Moos
@d-moos
hi!
if we use the @ngrx/router-store, should we update the router-state (specifically queryparams) directly or should we dispatch an action?
ChrisGibb
@ChrisGibb
Hello. I have a question about getWithQuery on collection services. When I called this method I am not able to use catchError for trapping API errors. Looking at the implementation of getWithQuery I notice that it's dispatching an action to make the request to the api, so the error is not able to bubble back to my subscription. Does anybody have any experience with trying to catch API errors when using getWithQuery ?
Derek
@derekkite
@ChrisGibb is this ngrx/data?
ChrisGibb
@ChrisGibb
yes
ChrisGibb
@ChrisGibb
but that's the data service, not the collection service
the collection service dispatches an action, and isn't returning my error
do you have any advice?
seems strange I can't use catchError
should throw an error
ChrisGibb
@ChrisGibb
perhaps I'm confused. Please take a look here https://github.com/ngrx/platform/blob/0e9c4f4a20ca92a71ee331889109c7861708725f/modules/data/src/dispatchers/entity-dispatcher-base.ts#L270. On line 287 it's dispatching the action to go an make the request, the API error is happening in there somewhere. What I receive when I call this function is the response from this.getResponseData$... and what I'm noticing is that catchError is never triggered even though I can see an error occurred in network tab in my dev tools
However, if you're telling me that my catchError should definitely get triggered, specifically for api errors, then perhaps my problem lies elsewhere
It seems that there is a hook on the response action that should be returned by getWithQuery. I'd look at the configuration for the api call
ChrisGibb
@ChrisGibb
thanks @derekkite . i'll take a closer look at this. i must have made a mistake somewhere
dalu
@dalu

@dalu I'm no data expert, but there was a PR a couple of days ago which documents how to create custom selectors - I answered your SO question

belated thanks, it was a life-saver :)

dalu
@dalu
does anyone know how to set ngrx/data to always do pessimistic updates? Or let me rephrase that, ignore responses from the backend when doing add, update, delete
because i have a notification websocket that updates the cache, so doing double the work seems unnecessary, waste of traffic/bandwidth
naveen2451
@naveen2451
Do we have anything for this : Sharing data and state between micro front end applications via ngrx?
Stephen Adams
@Stephenradams
@naveen2451 are your micro front-end applications all part of a larger application. For example, you are using a micro app for a section of a larger application?
naveen2451
@naveen2451
@Stephenradams All of my applications are build in angular and using single-spa library to mount and dismount's app's.
CodeNinjaHarrison
@CodeNinjaHarrison
Hi, does anyone have any idea on how to register child entities using ngrx/data? do i need to make a custom reducer? if so how do i register a custom reducer using ngrx/data? the docs aren't really helpful :(
Stephen Adams
@Stephenradams
@naveen2451 ok, what I've found from using Angular Elements as the micro front-end apps, is that they have access to session data or you can use @Input() to pass data into the application. This can then be added to the Store using an Effect.
naveen2451
@naveen2451
@Stephenradams have you got any repos for referring it?
Derek
@derekkite

I have a typescript question. I'm extending Entity to extract relational keys from the entities.

export interface KeySelector<T>  {[keyname: string]: IdSelectorStr<T>}
export interface EntityDefinition<T> {
    selectId: IdSelector<T>;
    sortComparer: false | Comparer<T>;
    selectKey: KeySelector<T>;
}

and then in the createEntity function

const { selectId, sortComparer, selectKey }: EntityDefinition<T> = {
    sortComparer: false,
    selectId: (instance: any) => instance.id,
    selectKey: {'key': (instance: any) => instance.key},
    ...options,
  };

which is the default for an entity, to extract ids etc. It is being used like this:

export const adapter: EntityRelationAdapter<InventoryType> =
    createEntityRelationAdapter<InventoryType>({
        selectId: InventoryType => InventoryType.tid,
        selectKey: {
            resourcetype: InventoryType => InventoryType.resourcetype,
        }
    });

TS2322: Type '{ [key: string]: string[]; } | ((instance: any) => any)' is not assignable to type 'IdSelectorStr<T>'. is the error
Removing noimplicitany from tsconfig it works fine, but I'm trying to type my code to find errors (which I have)

Stephen Adams
@Stephenradams
@naveen2451 Sorry no, not yet. I am planning on making one, but currently this is an internal project I'm working on.
nunofreitasbotelho
@nunofreitasbotelho
async onUpdateComment(payload: {layerId: number, comment: string}) {
    this.store.dispatch(new AddComment(payload));
    await this.reloadPage();
  }

  async reloadPage() {
    this.store.dispatch(new LoadLayerCollection());
  }
Given this and that AddComment triggers a side-effect, how can i force the LoadLayerCollection to only happen after the effect is either success or fail?
Ian Jamieson
@ianjamieson

Hey guys, I used to be able to do the following with actions:

  @Effect()
  public myAction$: Observable<TheReturnedActionClass> = this.actions$.pipe(
    ofType(SomeOtherAction),
    mapTo(new TheReturnedActionClass())
  )

However, I am now creating actions with createAction method, which means I don't have access to the type of the action, for example:

  const theReturnedActionFunction = createAction('[ACtion] theReturnedActionFunction');
  @Effect()
  public myAction$: Observable<WHATGOESHERE?> = this.actions$.pipe(
    ofType(SomeOtherAction),
    mapTo(theReturnedActionFunction())
  )

Any ideas on how I can access the type for the WHATGOESHERE part. I guess I could just use Action, but then that will be different to the rest of my application

Derek
@derekkite
@ianjamieson https://github.com/ngrx/platform/blob/master/projects/example-app/src/app/books/effects/collection.effects.ts#L32
the types through the effect carry through from ofType() if you use an action creator
Ian Jamieson
@ianjamieson

Thanks @derekkite - I suppose I can turn off strict typing for class properties, at the moment I get linting errors if I define something like this:

  loadCollection$ = createEffect(() =>
    // ...
  );

I must do:

  loadCollection$: Observable<Action> = createEffect(() =>
    // ...
  );
emko
@emko
if my api data is already normalized and i am using entity do i need to convert the objects back into array in order to load the data?
Derek
@derekkite
@emko the entity data structure is {[id]: Data} where id is extracted from each Data structure via SelectId function. What does the normalized data look like?
emko
@emko
i have it like {entities: { categories: { 1: { data... }, ids: { categoryIds: [1,2,3 etc ] }
has many entities and its ids
im doin like ...state, categories: { entities: { ...state.categories.entities, ...action.entities.categories }, ids: [...new Set([...action.ids.categoryIds, ...state.categories.ids])] }, is that right?
or should i convert it back to array and use add
Many
Derek
@derekkite
@emko there are multiple entities with the same category? What I did is use the entityadapter which has {ids: [array of ids], entities: {id: data}}. Ids are different in each entity. I then added categories{ categoryname: [array of entities]}
nunofreitasbotelho
@nunofreitasbotelho
Is it a good practise to load an Action on a specific effect of a LoadSomethingSuccess (which in turn is loaded by an effect)?
nunofreitasbotelho
@nunofreitasbotelho
Or perhaps do something like this?
switchMap(response => [new AddCommentSuccess(response), new LoadLayerCollection(), new SelectLayer(null)]),
beefedtaco
@beefedtaco
hi there! i've made a couple changes to @ngrx/store-devtools that i'd like to try out on my machine. i'm confused on how to build it so i can consume the built version in my application. is there a readme out there that details the build process?
John Azzolina
@johnazzolina_twitter
hello -- looking for some guidance on complex ui components -- how much the ui should be controlled internally / locally by the component it's self and how much by the store
for example, if I have a parent item with some child items that can be selected / unselected and the selection state of those items doesn't matter to anything outside of this component, should I update the state of the app with the selection status or just handle the UI updates in the local component?
Dave Bush
@DaveMBush

@johnazzolina_twitter components are responsible for displaying state only. My rule of thumb is that top level route components get data from the store and send actions to the store and all business rules are handled in the store selector (or on the server).... all other components are dumb... that is, they get there data via @Input and send events to the parent via @Output.

Components MAY have logic that help the display... this is handled by component services using the @Component viewProviders attribute. This keeps your components clean and puts your logic in a location that is easily testable.

The main point is ... business logic in the selector... component logic in the service.

In your example, if only the components care than that is handled by the component service
I'm actually working on a document that tries to outline this and more... so all this is fresh on my mind.
Hope this helps. I'm off.
John Azzolina
@johnazzolina_twitter
it does - thank you
Derek
@derekkite
@johnazzolina_twitter as usual it depends. A rough rule of thumb that I use is data that needs to be transferred between components more than two levels of separation ie. component1 @Input => component2 @Input, the store makes it easier to sort out. Usually you get into multiple consumers and it can get very messy very quickly using the intercomponent communication mechanisms. Another is that I try to avoid parameterized selectors as much as possible, which means that some component state is either in the router params or a store property.
Your specific question about selection state is probably best left in the components, but there again it depends what you need to do with it. If a selector is then based on that selection state, maybe the store state is the place for it.