# Upgrade guide for Scheduler v4.0.4

## Deprecated legacy functions on DependencyModel

The `getSourceEvent()` and `getTargetEvent()` functions in `DependencyModel` was deprecated in favor of the `fromEvent` 
and `toEvent` getters. They will be removed in 5.0. If you use them, the following snippets shows how to update your
code:

**Old code:**

```javascript
const
    sourceEvent = dependency.getSourceEvent(),
    targetEvent = dependency.getTargetEvent();
```

**New code:**

```javascript
const
    sourceEvent = dependency.fromEvent,
    targetEvent = dependency.toEvent;
```

## Setting resourceMargin and barMargin per row

Two new fields called `resourceMargin` and `barMargin` was added to `ResourceModel`. When set, they will take precedence
over the `resourceMargin` and `barMargin` values configured on Scheduler. This allows you to control them on a per row 
basis.

As all fields, they can be supplied as data:

```json
[
  {
    "id": "resource1",
    "name": "Resource 1",
    "resourceMargin": 20,
    "barMargin": 5
  },
  {
    "id": "resource2",
    "name": "Resource 2"
  }
]
```

"resource1" above will use `resourceMargin : 20` and `barMargin : 5`, "resource2" will use the value configured on 
Scheduler.

Values can also be changed at runtime, the UI will reflect the changes:

```javascript
scheduler.resourceStore.first.resourceMargin = 20;
```

If you need some additional runtime logic, subclass `ResourceMargin` and define a getter for the field. Something 
similar to:

```javascript
class MyResource extends ResourceModel {
    get resourceMargin() {
        let margin;

        // Complex logic to determine margin

        return margin;
    }
}
```


<p class="last-modified">Last modified on 2023-10-26 8:19:20</p>