-
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
Harmonize Collection and Collection.gather #39
Comments
So looking at staltz/cycle-onionify#28 it seems the I guess |
@atomrc sorry for the lack of response. I'll copy and paste my response from another issue, since it pretty much sums up what I view as the future of collections:
I feel that I very much like the idea of blending them together, and in my mind this would address one of the biggest weaknesses in onionify. A standalone collection library could be useful, but the current collection codebase needs much love. I also recently read about a philosophy for creating libraries where you create simple, composable primitives as the base of the library. You then create a prebuilt component that addresses 80% of the common use case.
So here's what I would like to see happen:
This road also allows us to enable ongoing innovation instead of putting all of our onions in one basket. Other libraries might spring up and choose to also depend on the standalone collections library. Source: cyclejs/cyclejs#620 (comment) |
I am currently re-writing
@cycle/collection
in typescript (#28). In the process, I am asking myself a few questions about the API design. The main question I have is: do we really have to distinguishCollection
andCollection.gather
?They both have different behavior that I don't really understand:
Collection.gather
will wrap additional sources in streams whileCollection
won't. Why is that exactly? I find it pretty confusing, even more because those streams are created inside cycle/collection so cannot change over time (except with ashamefullySendNext
of course).In fact, I don't really see any real use cases for the
Collection
function, most of the time collections are tied to a model that evolves over time (I might be wrong about this!)My suggestion would be to remove the
gather
method and makeCollection
behave likegather
. This would induce some breaking changes, but I think we can be smart about default values and try to have the smallest footprint possible.It might be also time to implement the
sort
function to be able to reorder items of the collection (#3).This could be the signature of the new
Collection
function (actually the same as thegather
method):This means that the user will have to implement the
remove
case (by updating theitem$
stream) be we would benefit form a simpler API and it would remove the confusion about theadd$
https://stackoverflow.com/questions/41910459/in-cycle-js-collections-how-does-the-second-sources-stream-relate-to-the-first/41915677What do you think? I'd be happy to implement this.
The text was updated successfully, but these errors were encountered: