# App State Change

```lua
function appStateChange(string_stateName)
    log('app is switching to state: ' .. string_stateName);
end

return function()
    addEvent('appState', 'appStateChange'); --subscribe to appState changes
    keepAlive();
end
```

{% hint style="info" %}
Events are asynchronous coroutines.
{% endhint %}
