Skip to content

How does one reference current interval id from within lambda #23

@Turbine1991

Description

@Turbine1991

Hello, as the title requests - this is my code:

uint16_t intervalId = Timer.setInterval([intervalId]() {
  Serial.println("123");

  if (true) {
    Timer.cancel(intervalId);
  }
}, 1000);

It's sometimes very clean to cancel an interval from within itself based on control logic. Is there a way of doing this without Timer.cancelAll() (which does work for now)?

Thank you,
This is a great library by the way, it's resolved all blocking issues and is clean to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions