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

v2 - Provide a way to map callbacks and classes #152

Open
hoeken opened this issue Aug 11, 2024 · 3 comments · May be fixed by #115
Open

v2 - Provide a way to map callbacks and classes #152

hoeken opened this issue Aug 11, 2024 · 3 comments · May be fixed by #115
Assignees

Comments

@hoeken
Copy link
Owner

hoeken commented Aug 11, 2024

proposal from @mathieucarbou

Example:

#ifdef PSYCHIC_TO_ESPASYNCWS
  #include <espasyncws.h>
#endif

content:

#pragma once

#include "PsychicHttpServer.h"
#include "PsychicWebHandler.h"
#include "PsychicRequest.h"

using AsyncWebServer = PsychicHttpServer;
using AsyncCallbackWebHandler = PsychicWebHandler;
using AsyncWebServerRequest = PsychicRequest;

Note: I am not sure this is the right way to do it, it could also be done within the library classes, example right now I am trying to migrate by using that in a library:

#ifdef ESPCONNECT_USE_PSYCHIC
    using Server = PsychicHttpServer;
    using WebHandler = PsychicWebHandler;
#else
    using Server = AsyncWebServer;
    using WebHandler = AsyncCallbackWebHandler;
#endif

So this is scoped to only my classes, but if this concept works, why not extending it globally and have Psychic provide a mapping class.

@mathieucarbou mathieucarbou self-assigned this Aug 11, 2024
@hoeken
Copy link
Owner Author

hoeken commented Aug 11, 2024

I like approach #1 - keep everything centrally located and keep the Psychic classes tidy without a lot of #ifdefs scattered around.

@hoeken hoeken closed this as completed Aug 11, 2024
@hoeken hoeken reopened this Aug 11, 2024
@mathieucarbou
Copy link
Collaborator

I like approach #1 - keep everything centrally located and keep the Psychic classes tidy without a lot of #ifdefs scattered around.

that's my goal, but for some exceptions it won't be possible... I.e. not worth redefining a whole decorator class if only 1 or 2 methods names have changd

@hoeken
Copy link
Owner Author

hoeken commented Aug 11, 2024

@mathieucarbou if its just method names, or method parameters and not return values, we can add the compatibility functions directly to the class, no problem.

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

Successfully merging a pull request may close this issue.

2 participants