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
[WIP] Convert advanced-list to use cycle-collections #25
Conversation
@staltz have a look at the updated version. I've renamed I cleared up the rest of the language around |
Actually thinking about it, |
remove$ (tickers, ticker) { | ||
return tickers.remove(ticker); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure I understood correctly, this remove$
function was named like this to match the remove$
in the child sinks object. Right? So Collection matches those.
And what is the semantics of this? "How to map child sinks to reducers for the parent" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're on the money. The reasoning goes a little something like this.
tickers
is a collection of Ticker
components. It's immutable, because in Cycle values that change are streams.
tickers$
is a stream of tickers
, changing over time. It's a common and useful pattern to build that stream by fold
ing over a stream of reducers
.
Sometimes a component in a collection needs to send a message to it's parent. The most common example is a remove
button. However, taking the sinks of each component, wrapping it with an id and setting up a circular dependency takes a lot of boilerplate and adds a lot of syntactic noise to the application.
Instead we provide sink handlers to Collection
, which as you've noted map item sinks into reducers
, so that they can be used in the creation of tickers$
. Sink handlers are passed (state, item, sinkEvent)
but are then wrapped so that they're called as (state) => state
. This means the user is saved the trouble of setting up ids or isolation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, great explanation. 👍
Thanks @Widdershin this is looking good and getting better. I'm still bike-shedding on some details, but that's just a sign that I like what I see so far, and I want to also fully understand the essence of this solution. |
I've addressed most of your feedback @staltz. I'm just in the process of writing a nice readme. |
Great. Here's the repo: https://github.com/cyclejs/collection Let's start using 👍 Great stuff |
@staltz awesome, I've pushed up to that repo. How can I publish to |
I have to do the first publish, and then I'm able to add you as a contributor and then you'll be able to publish. |
Okay, well it should be ready to go when you have time to publish.
|
Awesome, thanks! 😺 |
01caa1c
to
87ae386
Compare
Closed in favour of #27 as this example is now gone! |
Yeah I moved this example as a "test" in cycle DOM, because that's what its purpose has always been. I didn't want people to look at this source code as an "example" of what they should be coding. |
I'm not sure if we should ever merge this, but this is mostly for the sake of discussion and feedback atm.