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

Changed to allow overlapping use when using @AsyncApiSub / @AsyncApiPub #511

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ChoSeoHwan
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

When using multiple @AsyncApiPub or @AsyncApiSub in one method, only the last document data is applied.

gateway
image

docs
image

What is the new behavior?

If multiple @AsyncApiPub or @AsyncApiSub are used in one method, all applied document data is applied.

docs
image

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@ChoSeoHwan
Copy link
Author

I know how to use it like below,

  @AsyncApiSub(
    {
      channel: EventPatternsWS.createFeline,
      message: [
        {
          name: 'oneOf demo #1',
          payload: FelineRto,
        },
        {
          name: 'oneOf demo #2',
          payload: FelineExtendedRto,
        }
      ]
    },
    {
      channel: EventPatternsWS.wantFeline,
      message: {
        payload: FelineRto,
      }
    }
  )
  async emitCreatedFeline(felineRto: FelineRto) {
    this.server.emit(EventPatternsWS.createFeline, felineRto);
  }

Duplicated use of @AsyncApiSub/@AsyncApiPub will give users more options.

For example, if there is an event commonly used in multiple projects,
You can declare Decorator in advance in a common file and redundantly declare it in addition to existing events if necessary.

common

export const AsyncApiRefreshToken = () => AsyncApiSub({
  channel: 'common/refresh_token',
  message: {
    payload: TokenDto
  }
});

gateway

  @AsyncApiSub(
    {
      channel: EventPatternsWS.createFeline,
      message: [
        {
          name: 'oneOf demo #1',
          payload: FelineRto,
        },
        {
          name: 'oneOf demo #2',
          payload: FelineExtendedRto,
        }
      ]
    }
  )
  @AsyncApiRefreshToken()
  async emitCreatedFeline(felineRto: FelineRto) {
    this.server.emit(EventPatternsWS.createFeline, felineRto);
  }

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.

None yet

1 participant