# Callbacks

1. OnItemAdded / OnItemRemoved&#x20;

Useful if you want to do different things depending on if an item is added or removed. To see an example of this, click on the VfxSpawner.cs.&#x20;

Here we want to display a different VFX depending on if a player has been spawned or destroyed. The player argument is useful, as we can get its position and spawn the VFX there.&#x20;

```csharp
 public void Awake()
{
    scriptableListPlayer.OnItemRemoved += OnPlayerDestroyed;
    scriptableListPlayer.OnItemAdded += OnPlayerSpawned;
}

public void OnDestroy()
{
    scriptableListPlayer.OnItemRemoved -= OnPlayerDestroyed;
    scriptableListPlayer.OnItemAdded -= OnPlayerSpawned;
}

private void OnPlayerSpawned(Player player)
{
    Instantiate(_spawnVFXPrefab, player.transform.position, Quaternion.identity, transform);
}

private void OnPlayerDestroyed(Player player)
{
    Instantiate(_destroyVFXPrefab, player.transform.position, Quaternion.identity, transform);
}
```

2. Modified

This event is useful if you only care about when the number of elements in the list is changed.&#x20;

The example for this one is the ListCount.cs &#x20;

Scene Hierarchy: UICanvas/Bottom/ListCount&#x20;

```csharp
void Awake()
{
    scriptableListPlayer.Modified += UpdateText;
}

private void OnDestroy()
{
    scriptableListPlayer.Modified -= UpdateText;
}

private void UpdateText()
{
    _text.text = $"Count : {scriptableListPlayer.Count}";
}
```

We simply update the text with the number of elements in the list.&#x20;

3. OnItemsAdded / OnItemsRemoved&#x20;

This event is useful if you don’t want the OnItemAdded/OnItemRemoved event triggered every time you add/remove an item. This will be called once after a range of items have been added/removed. &#x20;
