Skip to content
This repository was archived by the owner on Jun 6, 2019. It is now read-only.
This repository was archived by the owner on Jun 6, 2019. It is now read-only.

Ability to return null #4

@wallzero

Description

@wallzero

A common issue I've run into with RxR reducers is accessing state. The reducers must return state, but in some workflows a reducer is going to call other reducers. For example, here in fetchClientsReducer$.

If you nest the reducer calls in the curried function, then the state modifications made by those calls will be wiped when you return the old state:

(something) => (state) => {
  //Call another reducer:
  actionStreams.commonReducer$.next({...state.something, ...something});
  // Returning this state will now undo the changes made by commonReducer
  return state;
}

You can do:

(something) => {
  actionStreams.commonReducer$.next({...state.something, ...something});
  return (state) => state;
}

But then you don't have access to state.

I think reducers should have the option to return nothing or return undefined, and RxR should know the reducer doesn't modify state.

(something) => (state) => {
  //Call another reducer:
  actionStreams.commonReducer$.next({...state.something, ...something});
}

When I try this now, my state object is wiped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions