-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Add' from child to parent #18
Comments
Definitely something worth considering, and the Can you think of an example of a real world application where this functionality might be needed? It's easier to solve problems when they're less abstract. |
Maybe even separate const parentAdd$ = ......;
const items$ = Collection(Item, sources, item =>
xs.merge(
item.add$,
parentAdd$
), item => item.remove$
}); Then current examples just change to |
But the problem here is that we risk to end up merging |
Btw, this assymetry of external adds vs internal removes resembles REST, where POSTs are made on collection's path, and DELETEs on item's |
Any list of stuff where an item has a "duplicate this" button. Seems quite common. :)
That may work! We could experiment. |
I second this. I currently have a use case for it, where I have a tree structure wherein the branches and leaves can be duplicated. |
This can be achieved using const duplicateProxy$ = xs.create();
const addClick$ = DOM.select('foo').events('click').mapTo({});
const add$ = xs.merge(
addClick$,
duplicateProxy$
);
const items$ = Collection(Item, sources, add$);
const duplicate$ = Collection.merge(item => item.duplicate$);
duplicateProxy$.imitate(duplicate$); Although, I personally prefer to pull any circular deps into the library itself. It also seems like this could be supported by allowing a function to be passed in place of |
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 areducerSelector
argument:Just exploratory suggestions.
The text was updated successfully, but these errors were encountered: