collection
collection copied to clipboard
Collection.gather requires identical names for values of type Item and Stream<Item>
While using something like Collection.gather(Task, sources, fetchedTasks$, 'uid') , I have to make sure fetchedTasks$ has objects where the property item is actually named item$. No idea why. This requires me to use a transformer like this:
function crazyHack(subCols: Stream<SubForCollection[]>): Stream<any> {
return subCols.map( scs => scs.map(sc => {
return {
// For some reason, Collection wants submission to
// be named submission$
submission$: sc.submission,
submission_id: sc.submission_id
};
}))
I then call e.g., Collection.gather(Task, sources, crazyHack(fetchedTasks$), 'uid').
This happened during an automatic refactor of naming submission to the more appropriate submission$ and took me hours to find, so I would advocate removing this dependence if possible.
gather uses the keys from snapshot object as keys for sources: https://github.com/cyclejs/collection/blob/master/src/collection.js#L201. I don't think it should append dollar sign automatically, but maybe it could accept a transformKey: (String) => String function as an argument
That sounds reasonable to me!