I am newbie and I am not familiar enough with delegates and lambda statements. So it might too simple but here is my issue:
I am trying to implement async subscription method with 2 argument by using command binding in Xamarin. When I wrote the command initializing shown below, code editor says
Action does not take two arguments
So what should I do to utilize two argument async methods for command binding?
//Command initializing line cause an error which says " Action<object> does not take two arguments.
Subscribe = new Command(async (productId,payload) => await SubscribeAsync(productId,payload));
....
public async Task<bool> SubscribeAsync(string productId, string payload)
{...}
I found a way to accomplish it, passing an object which contain all necessary parameters. Actually, @Junior Jiang suggested that. But I was also looking to code it in one-line lambda notation.
Here is my solution.
public SubscriptionViewModel()
{
subscriptionInfo = new SubscriptionInfo("s01", "payload");
Subscribe = new Command<SubscriptionInfo>(async (s) => await GetSubscritionsOptsAsync(this.subscriptionInfo));
...
}