mobx-utils icon indicating copy to clipboard operation
mobx-utils copied to clipboard

Enhancement - ObservableGroupMap discard undefined/null

Open ProTip opened this issue 5 years ago • 1 comments
trafficstars

I have a use case where I'm grouping items that may not have the keys present needed to generate a grouping key. In these cases I would actually prefer to not group them at all(vs dumping them in a catch-all bucket). I could envision other use cases where the the decision to group or not may be useful.

Current behavior appears to actually group every item with an undefined key into the same array? If so I would propose the option to discard items that have an undefined groupBy key.

ProTip avatar Jul 29 '20 16:07 ProTip

Not grouping items which have an undefined groupBy value is sensible. Unfortunately at this point changing it for everything would be a breaking change. Is the "catch-all" bucket causing a specific problem which would make it worth adding an option?

EDIT: Adding a symbol NOGROUP, which the groupBy function could return, would be a backwards compatible option which wouldn't require an option.

NaridaL avatar Jul 30 '20 08:07 NaridaL