ngneat / effects

🪄 A framework-agnostic RxJS effects implementation
https://www.netbasal.com
MIT License
63 stars 11 forks source link

some of feature #17

Closed LinboLen closed 2 years ago

LinboLen commented 2 years ago

Which @ngneat/effects-* package(s) are relevant/releated to the feature request?

effects

Description

  1. export Action from @ngneat/effects not @ngneat/effects/lib/actions.types
  2. support update list with entities
  3. a simple example for reducer feature

Proposed solution

  export class ReducerEffect {
    reducerEffect = createEffect((actions: Actions) => {
      return actions.pipe(
        tap((action) => {
          switch (action.type) {
            case NsActions.ActionTypes.Add:
              return nsStore.update(addEntities(action.dataList));
           case NsActions.ActionTypes.Update:
              return fromPagesStore.update(updateEntities(action.data.id, action.data)); <---- direct to use `action.data`

export Action then can create class Action

Alternatives considered

no more

Do you want to create a pull request?

No

NetanelBasal commented 2 years ago

@yackinn

yackinn commented 2 years ago

@LinPoLen I'm not sure what the issue is about. Are you reporting a bug or is this a feature request?

Can you setup a minimal reproduction if this is a bug?

LinboLen commented 2 years ago

ngrx have

const adapter: EntityAdapter<Data> = createEntityAdapter<Data>();
adapter.updateOne(action.page, state);
adapter.updateMany(action.list, state);

but ngneat updateEntities ( updateOne and updateMany ) must provide ids. should provide Partial<Entity> will be fine SomeStore.update(updateEntities(action.data.id, action.data));

yackinn commented 2 years ago

https://ngneat.github.io/elf/docs/features/entities/entities

You can do partial updates.