Sharing state with callbacks?

I have a class that looks like this:

```
class BgDataService extends System.ServiceDelegate {
hidden var sessionId;

// override
(:background_method)
function onTemporalEvent() {
if (sessionId == null) {
Communications.makeWebRequest(..., method(:loginResponseCallback))
}
...
}

(:background_method)
function loginResponseCallback(responseCode as Lang.Number, data as Lang.String) as Void {
sessionId = ...
}
}
```

The problem the value set to `sessionId` in the callback is not visible in `onTemporalEvent` when it's called the next time.

Is this expected? How do I share this state (sessionId) with the callback?

Top Replies

All Replies