Skip to content

feat(reducers): CLEAR_COLLECTION, to clear a specified collection  #282

Open
@RavenousPett

Description

What is the feature?
A reducer to handle an action similar to CLEAR_DATA, however takes a parameter to clear firestore.data.{some param}

What version would this apply to?
Next

Do you have thoughts/examples on how the feature would be used (i.e. API)?
Example use in an application actions file:

export const unmountSportsCar = () => {
  return (dispatch) => {
    dispatch({ type: actionTypes.CLEAR_COLLECTION, payload: {collection: 'sponsors'}})
  }
};

Example of why this would be useful

  • I have an app that contains multiple sports cars. I click to view a sports car and also see a list of sponsors for that car. Sponsors is a subcollection of a sports car.
  • When I click to view another sports car the sponsors from the first sports car remain in the firestore.data.sponsors state. This means they are briefly visible on the page until the sponsors for the next car have loaded from firestore
  • When I unmount the sports car component I would like to dispatch a CLEAR_COLLECTION event to remove the sponsors from the firestore state.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions