Skip to content
This repository was archived by the owner on Apr 22, 2021. It is now read-only.
This repository was archived by the owner on Apr 22, 2021. It is now read-only.

Getting related model in change handler for has-one relationship #58

Description

@kevindente

Maybe I'm missing something, but currently there doesn't seem to be a clean way to do the following for a has-one relationship:

  1. Listen for the change of a related model
  2. In the event handler for the change, access the new value.

For example, assume Foo has-one Bar. You can listen for a change in Foo's Bar property using foo.on('change:bar_id', handler). But in the handler, you can't currently use foo.bar() to access the new property. This is because in One.replace, the code is:

  model.set(this.id, other.id);
  model[this.store] = other;

So the change gets triggered before the child model gets stored back on the parent.

Is this by design? A bug? Is there another way to accomplish this?

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