Skip to content

Instantly share code, notes, and snippets.

@arthurgubaidullin
Created September 5, 2021 16:49
Show Gist options
  • Save arthurgubaidullin/9695610cd8680fc0fbc78043f5a62853 to your computer and use it in GitHub Desktop.
Save arthurgubaidullin/9695610cd8680fc0fbc78043f5a62853 to your computer and use it in GitHub Desktop.
interface InternalEventBrand {
readonly Internal: unique symbol;
}
type User = {}
type AuthorizedEvent = { type: 'AUTHORIZED'; user: User } & InternalEventBrand;
function authorized(user: User): AuthorizedEvent {
return { type: 'AUTHORIZED', user } as AuthorizedEvent;
}
type UnauthorizedEvent = { type: 'UNAUTHORIZED' } & InternalEventBrand;
function unauthorized(): UnauthorizedEvent {
return { type: 'UNAUTHORIZED' } as UnauthorizedEvent;
}
export type AuthEvent =
| { type: 'AUTHORIZATION' }
| AuthorizedEvent
| UnauthorizedEvent
| { type: 'SIGN_IN' }
| { type: 'SIGN_OUT' };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment