Skip to content

Extended observer does not notify when the base attribute changes #245

@frmdstryr

Description

@frmdstryr

Consider the following:

from atom.api import Atom, Int, Typed, observe
class Pt(Atom):
    x = Int()
    y = Int()

class Item(Atom):
    pos = Typed(Pt, ())

    @observe('pos.x') # adding 'pos' here makes it change
    def on_change(self, change):
        print(change)

item = Item()
item.pos.x = 1 # This triggers on_change
item.pos = Pt(x=2, y=0) # This does not trigger on_change

When running the code above it prints:

{'type': 'create', 'object': <__main__.Pt object at 0x7527f06a6640>, 'name': 'x', 'value': 1}

But it seems like it should probably have also printed an update?

{'type': 'update', 'object': <some new Pt>, 'name': 'x', 'oldvalue': 1, 'value': 2}

I'm not sure if the current behavior is expected or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions