JamesRandall / FunctionMonkey

Write more elegant Azure Functions with less boilerplate, more consistency, and support for REST APIs. Docs can be found at https://functionmonkey.azurefromthetrenches.com
MIT License
294 stars 50 forks source link

Improvements suggestion: multiple output bindings #127

Open alexeymarkov opened 4 years ago

alexeymarkov commented 4 years ago

Hi James,

Have you thought about adding a support of multiple output bindings? Imagine, in a POST/PUT/DELETE http function would like to

One could use benefits of multiple output bindings and return a set of values. For instance,

class MultipleResult
{
public MyPoco ReturnResult { get; set; }
public string ServiceBusMessage { get; set; }
public SignalRMessage SignalRMessage  { get; set; }
}

class MyCommand : ICommand<MultipleResult>

Along with IFunctionOptions.OutputTo property there could be a method MultiOutputTo(Expression<Func<TResult, object>> propertySelector) which would extract the property name from propertySelector and store it into a corresponding output binding class as an optional property name.

.MultiOutputTo(x => x.ServiceBusMessage).ServiceBusQueue(...) .MultiOutputTo(x => x.SignalRMessage).SignalRMessage(...)

Also something like IFunctionOptions.BindResultTo((Expression<Func<TResult, object>> propertySelector) to specify a property name to used as a function result (if any) would be necessary.

Sure, templates have to be adjusted.

What do you think?

Regards, Alexey

JamesRandall commented 4 years ago

I think its a good idea! I'll add it to the list! Thank you :)