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 on session change callback #269

Merged
merged 4 commits into from
Feb 9, 2024
Merged

Conversation

MarshalX
Copy link
Owner

@MarshalX MarshalX commented Feb 8, 2024

closes #268

Usage example:

from atproto import Client, SessionEvent, Session


client = Client()

@client.on_session_change
def on_session_change(event: SessionEvent, session: Session) -> None:
    print(event, session)

# or without decorator:
# client.on_session_change(on_session_change)

client.login('handle', 'pass')

Async usage example:

from atproto import AsyncClient, SessionEvent, Session

client = AsyncClient()

@client.on_session_change
async def on_session_change(event: SessionEvent, session: Session) -> None:
    print(event, session)

# or without decorator:
# client.on_session_change(on_session_change)

await client.login('handle', 'pass')

@MarshalX
Copy link
Owner Author

MarshalX commented Feb 8, 2024

@grantmcconnaughey any suggestions?

@MarshalX MarshalX merged commit c12c915 into main Feb 9, 2024
25 checks passed
@MarshalX MarshalX deleted the add-on-session-change-callback branch February 9, 2024 20:46
@grantmcconnaughey
Copy link

Sorry for the delay! This looks great, and I really appreciate you writing up that documentation. 🙏

@MarshalX
Copy link
Owner Author

MarshalX commented Feb 9, 2024

@grantmcconnaughey This has been released in https://github.com/MarshalX/atproto/releases/tag/v0.0.41

btw as i understand postpone uses atproto SDK? may i mention it in the repo`s readme in a section like "Who uses The AT Protocol SDK for Python"? or maybe you have a page where you mention used open source projects

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 this pull request may close these issues.

Auth token handling improvements
2 participants