Skip to content

question(query): Scaleable decoupled patterns #417

Open
@Floriferous

Description

@Floriferous

In my thunks where I somehow access the database, I always have to extract firebase first, before injecting it inside a module that should hide firebase as much as possible:

// addTodo module handles all the firebase specific issues, errors, subcollections, etc.
import addTodo from '.../api/addTodo';

export const insertProduct = values => (
  dispatch,
  getState,
  { getFirestore },
) => {
  const { add } = getFirestore();

  return addTodo(add, { otherParameters })
};

Is there a way to write these more like this, and remove all the firebase access from thunks? :

import addTodo from '.../api';

export const insertProduct = values => (
  dispatch,
  getState,
) => {
  // Nice abstraction around firebase/firestore
  // Magically adds a todo to firebase without this action knowing about firebase
  return addTodo({ otherParameters })
};

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions