Skip to content

change:a.x fired, while no change:a firing? #257

@claydodo

Description

@claydodo

I'm using ampersand-state 4.9.1 and have a State defined like this:

var MyState = State.extend({
    props: {
        a: 'state'
    },
    
    setA: function(x, y) {
        this.a.set({x: x, y: y});
    }
})

where a is always an instance of A:

var A = State.extend({
    props: {
        x: 'number',
        y: 'number'
    }
})

When using MyState's instance someObj.setA(3, 5), etc, I find that the following events are fired:

  • change:a.x
  • change:a.y
  • change (someObj's own change event)

But there's no change.a fired, which is desired. Because in my app I want to observe MyState's change:a to handle the changes of x and y at the same time, instead of observing change:a.x and change:a.y (which suites other scenarios, though) as independent events.

Is this an issue worth consideration? Or am I using sub-states in a wrong way?

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