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 Function to Retrieve Channels by Address #104

Open
KhudaDad414 opened this issue Nov 20, 2023 · 2 comments
Open

Add a Function to Retrieve Channels by Address #104

KhudaDad414 opened this issue Nov 20, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@KhudaDad414
Copy link
Member

Context

I currently retrieve a channel based on its address using the following code snippet:

parsedAsyncAPI.channels().all().filter((c) => c.address() === address)

This approach, while functional, can be verbose and less intuitive for developers who frequently need to access channels by their address.

Proposed Solution

I propose the addition of a getByAddress or a similar function to the parser-api. This function would allow users to directly retrieve a channel based on its address in a more concise and readable manner. The proposed usage would be:

parsedAsyncAPI.channels().getByAddress(address)
@KhudaDad414 KhudaDad414 added the enhancement New feature or request label Nov 20, 2023
Copy link

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@fmvilas
Copy link
Member

fmvilas commented Nov 20, 2023

I like it. My only concern is that multiple channels can have the same address so I think it should become .filterByAddress() instead. The method should return a collection (not an array), so we can filter it using other helper methods proposed at #105.

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

2 participants