Skip to content

'Add' from child to parent #18

@staltz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions