# PropertyTreeChangeEvent Questions

**URL:** <https://forum.inductiveautomation.com/t/propertytreechangeevent-questions/86707>\
**Category:** Module Development\
**Tags:** perspective\
**Created:** [March 1, 2024, 11:24pm UTC](https://forum.inductiveautomation.com/t/propertytreechangeevent-questions/86707 "2024-03-01T23:24:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [March 1, 2024, 11:24pm UTC](https://forum.inductiveautomation.com/t/propertytreechangeevent-questions/86707/1 "2024-03-01T23:24:48Z")

</div>

I'm trying to subscribe to property changes in my component model delegate, and usage of ` PropertyTreeChangeEvent` is tripping me up.

My goal: subscribe to an array of objects at path `this.props.tags`.

1: Why do I have to call `resolveReference()`? How is that different than startup?

```auto
override fun onStartup() {
    log.infof("Starting up delegate for '%s'!", component.componentAddressPath)
    tags = component.createPropertyReference("this.props.tags", onValueChange, Origin.ANY)
    tags.resolveReference()
    tags.startup()
}

```

2: What is the distinction between these two?

```auto
val onValueChange: (changeEvent: PropertyTreeChangeEvent) -> Unit = { changeEvent ->
    changeEvent.readValue() // Maybe an array of a QualifiedValues? Why?
    changeEvent.readCausalValue() // This one seems to make more sense.
}

```

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [March 4, 2024, 3:26am UTC](https://forum.inductiveautomation.com/t/propertytreechangeevent-questions/86707/2 "2024-03-04T03:26:54Z")

</div>

Answered my own question 2:

```auto
changeEvent.readValue() // Returns the value of the subscribed property. i.e. always "this.props.tags"
changeEvent.readCasualValue() // Returns the value of the property at the path that changed. i.e. possibly "this.props.tags[0].tagPath"
```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 4, 2024, 4:24pm UTC](https://forum.inductiveautomation.com/t/propertytreechangeevent-questions/86707/3 "2024-03-04T16:24:05Z")

</div>

You don't want to use `createPropertyReference`; that's more "internal"/"under the hood" machinery. If you want to subscribe, you should be...subscribing 🙂

First, obtain the backend `PropertyTree` for your property type:  
`props = component.getPropertyTreeOf(PropertyType.props);`

Then you can issue a one-time read:  
`props.read("path").orElse(null)`

Or create a subscription:  
`props.subscribe("path", Origin.ANY, someLambda)`

You should maintain that list of `Subscription`s returned by `subscribe`, and in your model's `onShutdown` make sure each one unsubscribes.

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [March 4, 2024, 4:34pm UTC](https://forum.inductiveautomation.com/t/propertytreechangeevent-questions/86707/4 "2024-03-04T16:34:01Z")

</div>

Awesome, thanks Paul.  
I thought the whole thing seemed more convoluted than necessary 😆
