8000 Consider replacing `ChangedOnly` by more composable predicates · Issue #345 · frequenz-floss/frequenz-channels-python · GitHub
[go: up one dir, main page]

Skip to content
Consider replacing ChangedOnly by more composable predicates #345
Closed as not planned
Closed as not planned
@llucax

Description

@llucax

What's needed?

It still seems hard to justify the special case, in particular because if we add more simple predicates it could be really easy to get ChangedOnly while allowing to create more types of predicates more easily.

Specially once #354 and #355 are implemented.

Proposed solution

If we add these:

def is_equal(prev_message: object, new_message: object) -> bool:
    """Return whether `prev_message` is equal to `new_message`."""
    return prev_message == new_message


def is_same(prev_message: object, new_message: object) -> bool:
    """Return whether `prev_message` is the same instance as `new_message`."""
    return prev_message is new_message

Then ChangedOnly is basically is drop_while(is_equal), which it is a bit more verbose, but actually makes it more obvious what's really going on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    part:experimentalAffects the experimental packagetype:enhancementNew feature or enhancement visitble to users

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0