Skip to content

Commit

Permalink
feat: implement Subscription type
Browse files Browse the repository at this point in the history
  • Loading branch information
leynier committed Oct 17, 2021
1 parent a6dacaf commit 8c64876
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion gotrue/lib/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, Optional
from typing import Any, Callable, Dict, Optional

from gotrue.lib.helpers import parse_none

Expand Down Expand Up @@ -199,6 +199,19 @@ def to_dict(self) -> Dict[str, Any]:
return data


@dataclass
class Subscription:
id: str
"""The subscriber UUID. This will be set by the client."""
callback: Callable[["AuthChangeEvent", Optional[Session]], None]
"""The function to call every time there is an event."""
unsubscribe: Callable[[], None]
"""Call this to remove the listener."""

def __post_init__(self) -> None:
self.id = str(self.id)


class AuthChangeEvent(str, Enum):
SIGNED_IN = "SIGNED_IN"
SIGNED_OUT = "SIGNED_OUT"
Expand Down

0 comments on commit 8c64876

Please sign in to comment.