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

Add a replaceSession function to ovewrite the session data instead merging it. #773

Closed
1 task done
remonke opened this issue Jun 14, 2024 · 1 comment
Closed
1 task done
Labels
enhancement New feature or request

Comments

@remonke
Copy link
Contributor

remonke commented Jun 14, 2024

Describe the feature

If I want to use discrimated unions for session types in my app, I currently have to do this:

type AppSessionData =
  | {
      type: undefined;
    }
  | {
      type: 'pending-oauth';
      payload: {
        provider: AppOauthProvider;
        providerId: string;
      };
    }
  | {
      type: 'active';
      payload: {
        id: number;
        userId: number;
      };
    };

Honestly, I'm not a big fan of this approach.
I think it would nice if there was a function like replaceSession to simply assign a new object to session.data instead of doing Object.assign.

Additional information

  • Would you be willing to help implement this feature?
@remonke
Copy link
Contributor Author

remonke commented Jun 14, 2024

Okay I can simply use a different session name for this.

Sorry for being so retarded.

@remonke remonke closed this as completed Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant