Difference between Async.function and Async.procedure in cadence - cadence-workflow

Team,
I don't know the difference between Async.function and Async.procedure
Let me know when to use where

Async.function can return a value but Async.procedure doesn't.
Also, Functions.Func1 allow to pass a parameter, Functions.Func2 allow to pass two parameters, etc

Related

Recommended way of passing cacheKey to selectFromResult and onQueryStarted in RTKQ

In RTKQ-documentation example cacheKey is undefined, but usually that is not the case. My current solution is to save cacheKey in a slice which makes it available both to selectFromResult and onQueryStarted (essentially everywhere) but I feel it is less than perfect. Is there some recommended way of storing and reusing cacheKey in RTKQ?
I think you might be using wrong terms here. cacheKey is an internal string representation of your argument and you will never interact with that string in RTK-Query.
You will need the same argument in some cases.
In onQueryStarted of a query, you might just be able updateCachedData from the lifecylce api, so you do not need the argument.
For selectFromResult, you will need to pass the same argument into the hook as you did elsewhere. In that case, you can either pass it down to a child using props or share it using Redux state.

Kentico Nested Macro Comparison

I want to compare a url to a specific path to see if they match. I have tried so many variations and just can't get it to work, the two items I need to use are
{%CurrentDocument.RelativeURL.Replace("~","")%}
and
{&/{0}/{1}/{2}|(tolower)&}
In the current test scenario, both of these return the same string, however, when I put them together
{%CurrentDocument.RelativeURL.Replace("~","")|(equals){&/{0}/{1}/{2}|(tolower)&}|(truevalue)yes#%}
I get a false result displaying, I'm pretty positive it's because I can't nest a path expression inside an expression but not sure if there is another way? Any help would be appreciated.
Thanks
According to the documentation you should be able to substitute path macro with {%Path.path%}. Then there is no need to nest different types of macros but use the Path the same way as CurrentDocument.

G-WAN: how to get rid of the "?" in URL and how to set default language?

In G-WAN the default URL is in the form mydomain.com/?hello.c
I want to get rid of the ? to have URLs that look like mydomain.com/hello
The user manual mentions substituting a different character such as ' for ?. In that case the URL would look like mydomain.com/'hello.c
But I don't want to use a different character, I want to get rid of the special character completely. Is that possible?
The default language for G-WAN is C. So mydomain.com/?hello means mydomain.com/?hello.c
How do I change the default to a different language, say Java, so that mydomain.com/?hello now means mydomain.com/?hello.java
Can I set different default languages for different virtual hosts?
Finally, how do I change the URL format for passing parameters? According to the user manual the default format is:
mydomain.com/?hello.c&name=Eva
I want to change it to:
mydomain.com/hello?name=Eva
Is that possible?
This has already been asked many times, and a few solutions are found here:
G-WAN handler rewriting solution
You should note, however, that the way you mean to pass arguments as ?something=answer instead of & only applies to the first argument passed. You can't do ?this=that?somethingelse=this because only the first can be ? and the rest must be &. In fact you can ignore using ? completely and only use & with virtually unlimited arguments so it's in fact better to stick to only using &.
It's important to note for future reference to anyone asking similar questions, G-WAN gives you the entire headers through multiple steps of the HTTP transaction and being that you can modify them with c/c++, you can change anything at all that you want before the requests are handled by the server or sent back to the client. The only limitation is your knowledge and imagination.

Does the locale belong on the path or as a request parameter on the URI?

I have seen the locale added to an URI as a path variable:
/en-US/blah/
or
/blah/en-US
and I have seen it as a request parameter:
/blah?lang=en-US
Is there a standard way that I should be doing it? If not what are the pros and cons of each approach?
I kind of like the request parameter approach because it doesn't require you to pass the locale with every URI (unless you use the second approach and add the locale to the end of the path). Any additional thoughts?
I believe the "standard way" is to use an HTTP "accept language" header. Other than that, if you think it ought to be a parameter (because it's a system-system call or you might request a language other than the browser locale) then it's just a parameter the same as anything else and you should handle it in a similar fashion.
Fun fact: even with this notation "/blah/en-US" it could still be a request parameter. Magic of mod_rewrite and friends.
If you need it as request parameter or part of the url depends of what you want to achieve. If you want to serve static content, you should have it be part of the path. If you want to act dynamically on the chosen locale, you should use it as request parameter, since you don't want to have your scripts replicated several times over different paths just to add different locales.

Perl URL Control and validation

How can I validate a URL in perl. I mean, the query string has a specific order and all params have specific values (int or string or operator (%2B(+) ect..)).
example : www.mypage/question?name=john&age=21&operation=%2B
Can I control the order (name->age->operation) and the specific values of them?
Thanks
Yes and no.
No, you can't control the order of the parameters as they're submitted to you. Browsers may submit them in a different order, or the user may not be using a browser to submit the query to you.
Yes, you can control the order of the parameters you submit. But, don't rely on this.
You can use Data::Validate::URI to validate a URL.
You shouldn't use a complicated RegEx for controlling parameter values. Either the parameter matches or it doesn't. Either the parameter value is one of the expected options, or it isn't. If it matches, do something. If it doesn't match anything, don't do anything. (Or do a 404, but that can be leveraged against you.) Using anything more complex than "this parameter value should be all numbers" is asking for trouble.