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 property received will be false after the event reception
  • if the event PersistentEvent is received before waiting for it, the property received will be true after the event reception