Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop the implicit setup() and loop() definitions #16

Open
mairas opened this issue Nov 6, 2021 · 1 comment
Open

Drop the implicit setup() and loop() definitions #16

mairas opened this issue Nov 6, 2021 · 1 comment
Labels
2.0 Breaking changes for 2.0

Comments

@mairas
Copy link
Owner

mairas commented Nov 6, 2021

Current ReactESP implementation uses a somewhat special syntax, with the constructor expecting a lambda function or a function pointer that is called to setup the program:

ReactESP app([]() {
    setup_code_here();
});

The traditional Arduino Framework setup() and loop() functions still exist but are predefined in reactesp.cpp.

This is fancy but also gimmicky and potentially confusing for developers who have not worked with C++ lambdas before. But worse, this approach is limiting and discourages using ReactESP in more traditional Arduino projects.

Instead, I'd like to move back to a more traditional Arduino execution model in which the program setup() and loop() are defined explicitly:

ReactESP app;  // app is still defined but takes no arguments

void setup() {
  setup_code_here();  // setup() contains the same setup code as the previous lambda function
}

void loop() {
  app.tick();  // we have an explicit definition of loop() and call app.tick() manually
}

Besides being more obvious, a major added benefit is that with minor modifications, I think this approach would allow using ReactESP also with ESP-IDF instead of just the Arduino Framework.

@mairas
Copy link
Owner Author

mairas commented Sep 9, 2024

Fixed in v2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 Breaking changes for 2.0
Projects
None yet
Development

No branches or pull requests

1 participant