Skip to content
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

Collection.gather requires identical names for values of type Item and Stream<Item> #32

Open
bbarker opened this issue Feb 10, 2017 · 2 comments

Comments

@bbarker
Copy link
Collaborator

bbarker commented Feb 10, 2017

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.

@Hypnosphi
Copy link
Collaborator

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

@bbarker
Copy link
Collaborator Author

bbarker commented Feb 10, 2017

That sounds reasonable to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants