Persistent Event
If you need to take into account an event received before waiting for it, you can do something like:
*handle() {
...
if (this.received !== true) {
const event = yield this.wait.event("PersistentEvent").forever();
this.received = false;
}
...
},
*onEvent(name, ...data) {
if (name === 'PersistentEvent') {
this.received = true;
}
}
Note also that the onEvent
function is always called first when receiving an event. So:
- if the event
PersistentEvent
is received while waiting for it, the propertyreceived
will befalse
after the event reception - if the event
PersistentEvent
is received before waiting for it, the propertyreceived
will betrue
after the event reception