Skip to content

'Add' from child to parent #18

Description

@staltz

Here's a question or something to consider. I was staring at the Collection API and thinking about the 3rd parameter, add$. It assumes the add events are given from the parent to the collection of children. What if a child component has an add button that would create a neighbor on the list? How do we handle that?

Maybe with the handlers/reducer API this would have been simple: just specify the reducer when an event is emitted on item.add$. Perhaps the handler/reducer API could remain as a generic solution? And another thing to consider is a reducerSelector argument:

const parentAdd$ = ......;

const items$ = Collection(Item, sources, function reducerSelector(item) {
  const addReducer$ = xs.merge(
    item.add$.map(......),
    parentAdd$.map(......)
  );
  const removeReducer$ = item.remove$.map(......);
  const reducer$ = xs.merge(addReducer$, removeReducer$);
  return reducer$; 
});

Just exploratory suggestions.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions