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 optional payload for middlewares #1304

Merged
merged 10 commits into from
May 17, 2022

Conversation

aswetlow
Copy link
Member

Proposed Changes

Adds the possibility to add an optional payload parameter to the middleware run method. The payload parameter is always of type AnyObject.

I also added some properties to the payload object in internal functions.

// middleware `event.ComponentTreeNode.executeHandler` 
{
   componentName: string;
   handler: string;
}
// middleware `event.$resolve` 

{
   resolvedHandler: string;
   eventName: string;
   eventArgs: ARGS extends unknown[];
}

// middleware `event.$delegate` 
{
   componentName: string;
   options: DelegateOptions;
}
// middleware `event.$redirect` 
{
   componentName: string;
   handler: string;
}
// middleware `event.$redirect` 
{
   componentName: string;
   handler: string;
}
// middleware `event.$send` 
{
   outputConstructorOrTemplateOrMessage:  string
      | OutputConstructor<OUTPUT, REQUEST, RESPONSE, this>
      | OutputTemplate
      | OutputTemplate[];
   handler: DeepPartial<OUTPUT['options']>;
}

Usage in Jovo apps.

app.hook('event.ComponentTreeNode.executeHandler', (jovo, payload) => {
  console.log(payload.componentName);
  console.log(payload.handler);
});

This would improve/fix mentioned in #1292

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@aswetlow aswetlow requested a review from jankoenig April 27, 2022 12:53
Copy link
Member

@jankoenig jankoenig left a comment

Choose a reason for hiding this comment

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

Thanks! I just updated the docs and also added the $send payload

@aswetlow
Copy link
Member Author

👍 Ready to be merged

@jankoenig jankoenig merged commit 92cc9c6 into v4/dev May 17, 2022
@jankoenig jankoenig deleted the v4/feature/middleware-payload branch May 17, 2022 15:03
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