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

[Feature]: Group Operator with a Dynamic Grouping Key Selector #848

Closed
dwcullop opened this issue Feb 10, 2024 · 1 comment · Fixed by #849
Closed

[Feature]: Group Operator with a Dynamic Grouping Key Selector #848

dwcullop opened this issue Feb 10, 2024 · 1 comment · Fixed by #849
Assignees

Comments

@dwcullop
Copy link
Member

dwcullop commented Feb 10, 2024

Describe the functionality desired

A Grouping operator that supports the Group Key Selector changing dynamically, such as:

IObservable<IGroupChangeSet<TObject, TKey, TGroupKey>> Group(
    this IObservable<IChangeSet<TObject, TKey>> source,
    IObservable<Func<TObject, TKey, TGroupKey>> grouperObservable);

// Also maybe
IObservable<IGroupChangeSet<TObject, TKey, TGroupKey>> Group(
    this IObservable<IChangeSet<TObject, TKey>> source,
    IObservable<Func<TObject, TKey, TGroupKey>> grouperObservable,
    IObservable<Unit> regrouper);

The steps the functionality will provide

When groupObservable fires, it will regroup all the items according to the new Grouping Key selector function.

If regrouper is provided, it will re-evaluate the grouping using the current Grouping Key.

Considerations

Current Group operators don't support changing of the Group Key selector. The Group Key selector can be dynamically re-applied, but it can't be changed.

IObservable<IGroupChangeSet<TObject, TKey, TGroupKey>> Group<TObject, TKey, TGroupKey>(
this IObservable<IChangeSet<TObject, TKey>> source, Func<TObject, TGroupKey> groupSelectorKey, IObservable<Unit> regrouper);

GroupOnObservable allows for dynamic changing of the Group Key Value but on a per item basis.

@dwcullop dwcullop changed the title [Feature]: Group Operator that supports Dynamic Group Selection [Feature]: Group Operator with a Dynamic Grouping Key Selector Feb 10, 2024
@dwcullop dwcullop linked a pull request Feb 11, 2024 that will close this issue
dwcullop added a commit that referenced this issue Feb 14, 2024
Addresses #848 by providing new overloads for the `Group` operator that allow the user to supply a `IObservable<Func<TObject, TKey, TGroupKey>>` so that the function that is used to obtain the GroupKey can change dynamically.  When a new value is supplied, a new GroupKey will be obtained for each item, and if the GroupKey has changed, the item will be moved to the new Group.

Also allows for an optional `IObservable<Unit>` parameter that will force the current GroupKey selector to be re-applied to all the items.
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants