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

example: custom callback in event poller #33

Merged
merged 1 commit into from
Jun 8, 2023
Merged

Conversation

denverbaumgartner
Copy link
Contributor

@adamamsmith wanted to get your thoughts on this before writing up supporting docs, any other patterns/best practices you think we should show when it comes to event_handler on client.start_event_poller? could we be demonstrating this functionality in a better way? this is a great feature, let me know however i can be of help

@adamamsmith
Copy link
Contributor

I think the default pattern should not be to pass a custom event_handler to the event_poller as I think this is a bit hacky imo.

I think the default path should be as demonstrated here: #35

following the pattern developed here: #34

client.add_pair(pair_name="WETH/USDC") # , base_asset_allowance=Decimal("1"), quote_asset_allowance=Decimal("2000")

# start listening to offer events created by your wallet on the WETH/USDC market and the WETH/USDC orderbook
client.start_event_poller("WETH/USDC", event_type=EmitOfferEvent, event_handler=partial(compare_eth_offer, base_asset=base_asset, quote_asset=quote_asset))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this does work I think it is more complicated for users and shouldn't be advertised as the default path

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, i think the approach shown in #35 and more broadly in #34 is a much better approach, separates out the event handling logic to be based off the queue instead of at the event_poller level. lets definitely point user's to this pattern as the default, and we can simply have the event_handler buried a bit deeper with a clear breakdown of required structure for users who still choose to go this route.

@denverbaumgartner denverbaumgartner merged commit 7192ee3 into master Jun 8, 2023
@adamamsmith adamamsmith deleted the docs-examples branch June 9, 2023 07:32
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.

2 participants