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

Extend the type of dataKey to support function #232

Merged
merged 2 commits into from
Jun 9, 2020

Conversation

aisin
Copy link
Contributor

@aisin aisin commented Jun 7, 2020

What kind of this PR? (check at least one)

  • Feature

Other information:

Extend the type of dataKey to support function, so that the attributes in the object of dataSources can be converted into unique ID.

@aisin aisin changed the title Feat/extend data key Extend the type of dataKey to support function Jun 7, 2020
@tangbc
Copy link
Owner

tangbc commented Jun 9, 2020

I don't think it's necessary, it's flexible but make library becomes more complex to use, do you think?

@aisin
Copy link
Contributor Author

aisin commented Jun 9, 2020

It is indeed simpler to use, but it is too strict on business data and cannot meet some business scenarios, such as data-sources like this:

[
  {
    "cider": {
      "uid": 2261688
    },
    "chatData": {
      ...
    }
  },

  ...

  {
    ...
  }
]

In each item, cider.uid should be used as uniqueId.
And another data-sources example:

[
  {
    "cider": {
      "coid": 8618240,
      "ccid": 7413760
    },
    "chatData": {
      ...
    }
  },

  ...

  {
    ...
  }
]

There is not a field in each item object that can be used as uniqueId, but rather I need to generate one based on the given coid and ccid fields. However, since the item component is passed into the library as a prop, a function needs to be passed to generate the uniqueId.

@tangbc tangbc merged commit b491d0c into tangbc:master Jun 9, 2020
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

Successfully merging this pull request may close these issues.

2 participants